【问题标题】:Receive method in JMS waiting for messagesJMS中的接收方法等待消息
【发布时间】:2015-01-15 21:47:06
【问题描述】:

我想要一种方法来浏览消息队列中的所有消息,并可以使用 jmstemplate 和 Websphere 队列(不是 MQ)将其发送到另一个队列。我尝试使用接收,它能够从队列中检索所有消息,但它仍在等待另一条消息。并且消息正在丢失。必须在事务中

我尝试过的代码:

**String message = (String) jmsTemplate.receiveAndConvert();

System.out.print(message);

while ((message  =  (String) jmsTemplate.receiveAndConvert()) != null) {

      messages.add(message);

}
 return messages;
}**

【问题讨论】:

    标签: spring jms messages


    【解决方案1】:

    JMStemplate 只能用于同步读取或发送消息。对于异步读取,请使用侦听器实现之一。阅读here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-14
      • 1970-01-01
      • 1970-01-01
      • 2013-08-01
      • 2012-01-19
      • 2012-08-12
      • 2011-12-12
      • 1970-01-01
      相关资源
      最近更新 更多