Spring Batch / Integration - 接收消息

时间:2017-03-16 20:22:29

标签: spring-integration

我的java流程首先开始了它必须等到jms消息可用于activeMQ然后它应该读取JMS消息并执行java程序。我想要使​​用JMSTemplate。一旦执行,它应该退出。 我可以这样:           我可以使用while(msg == null)whithin,我可以接收msg并处理程序。最后我将使用System.exit

1 个答案:

答案 0 :(得分:0)

我想是的。

JmsTemplate

中也要注意这一点
/**
 * Receive a message synchronously from the default destination, but only
 * wait up to a specified time for delivery.
 * <p>This method should be used carefully, since it will block the thread
 * until the message becomes available or until the timeout value is exceeded.
 * <p>This will only work with a default destination specified!
 * @return the message received by the consumer, or {@code null} if the timeout expires
 * @throws JmsException checked JMSException converted to unchecked
 */
Message receive() throws JmsException;