hezhou opened SPR-16629 and commented

JmsTemplate with CachingConnectionFactory does not refresh resources, while sending message error. For example ,due to networking issues or server issues the server may take longer to answer than expected.. the client may timeout the call throwing an exception and the client could eventually retry another call with the same session, but the server could then answer a previous command. This may cause message loss.

DefaultMessageListener will renew the resource while receiveMessage error. why JmsTemplate not do like this.


Affects: 4.3.14

Comment From: snicoll

DefaultMessageListener will renew the resource while receiveMessage error. why JmsTemplate not do like this.

Sending is a one time operation that creates a session and close it at the end whereas the listener container has an active session listenning for new messages that it needs to handle in case of failure. What you've described could be a problem with the broker, not the use of the JMS API within JmsTemplate. Unfortunately, I can't know for sure as there is no way for me to reproduce this. If a reproducer is provided, we can review this again.