Java 我能';不要接受阿波罗MQ的消息。
当我连接Apollo MQ时,我得到的连接为true。但是,如果我试图从队列中获取消息,则得到的消息为null 我的连接代码是 ActiveMQConnectionFactory工厂=新的ActiveMQConnectionFactory(uName、pass、asBroker) 用于从队列接收消息的代码 公共可同步接收(字符串队列)引发ActiveSyncMQException{Java 我能';不要接受阿波罗MQ的消息。,java,Java,当我连接Apollo MQ时,我得到的连接为true。但是,如果我试图从队列中获取消息,则得到的消息为null 我的连接代码是 ActiveMQConnectionFactory工厂=新的ActiveMQConnectionFactory(uName、pass、asBroker) 用于从队列接收消息的代码 公共可同步接收(字符串队列)引发ActiveSyncMQException{ ObjectMessage message = null; Syncable syncPojo =
ObjectMessage message = null;
Syncable syncPojo = null;
try{
Destination destination = session.createQueue(queue);
MessageConsumer consumer = session.createConsumer(destination);
message = (ObjectMessage) consumer.receive(10000);
syncPojo = (Syncable) message.getObject();
}catch(JMSException jmsEx){
throw new ActiveSyncMQException("JMS exception while receiving message from queue("+queue+")", jmsEx);
}
catch(Exception ex){
throw new ActiveSyncMQException("Exception while receiving message from queue("+queue+")", ex);
}
return syncPojo;
}
您的队列上是否有消息?请检查您的生产者生产的队列名称和您消费的队列名称。检查生产者生产的代理和您消费的代理。尝试查看您在消息对象中得到的消息?包含消息的队列。队列名称是正确的。在apollo MQ的UI中,我可以看到线程正在消费。但它不是pick我正在整理这些信息。
ObjectMessage message = null;
Syncable syncPojo = null;
try{
Destination destination = session.createQueue(queue);
MessageConsumer consumer = session.createConsumer(destination);
message = (ObjectMessage) consumer.receive(10000);
syncPojo = (Syncable) message.getObject();
}catch(JMSException jmsEx){
throw new ActiveSyncMQException("JMS exception while receiving message from queue("+queue+")", jmsEx);
}
catch(Exception ex){
throw new ActiveSyncMQException("Exception while receiving message from queue("+queue+")", ex);
}
return syncPojo;
}