IIT Software wrote:
The question is why there is a transaction timeout at all. JMS local transactions never timeout and it is not spec compliant to call rollback/commit from another thread to terminate a receive. You can only call session.close from another thread. However, setting receiveTimeout=-1 will avoid this strange behavior to commit empty transactions every second. So you should use -1.
I think the reason the timeout exists is to allow the VM to exit. When I set the timeout to -1 with the spring app provided, the process hangs on exit. A thread dump reveals that this thread is still waiting on a receive() call with no timeout. I have to use "kill -9" to terminate the process.
"jmsContainer-1" prio=5 tid=0x01018b80 nid=0x82d800 in Object.wait() [0xb0f90000..0xb0f90d90]
at java.lang.Object.wait(Native Method)
- waiting on <0x255c51a8> (a com.swiftmq.jms.v630.QueueReceiverImpl)
at java.lang.Object.wait(Object.java:474)
at com.swiftmq.tools.util.UninterruptableWaiter.doWait(Unknown Source)
at com.swiftmq.jms.v630.MessageConsumerImpl.receiveMessage(Unknown Source)
- locked <0x255c51a8> (a com.swiftmq.jms.v630.QueueReceiverImpl)
at com.swiftmq.jms.v630.MessageConsumerImpl.receive(Unknown Source)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveMessage(AbstractPollingMessageListenerContainer.java:405)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:308)
at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:241)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:982)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:974)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:876)
at java.lang.Thread.run(Thread.java:613)