2017-03-16 105 views
0

我的java进程首先启动&它必须等到jms消息可用于activeMQ,然后它应该读取JMS消息并执行java程序。我想使用JMSTemplate。一旦执行,它应该退出。 我可以这样: 我可以使用while(msg == null),我可以接收msg并处理程序。最后我会用System.exitSpring批处理/集成 - 接收消息

回答

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; 
+0

谢谢,阿尔乔姆 – Raheem

+0

如果这是有帮助的,这个怎么样? http://stackoverflow.com/help/someone-answers –