Saving messages in the queue in the event of a receiver failure

We have a Spring JMS message listener container for asynchronously receiving messages. Using DefaultMessageListenerContainer and in sessionTransacted mode. I understand that in sessionTransacted mode, in case of an exception, the message will be returned to the queue. But how can I make sure that the message will not be removed from the queue, even if the receiver (which selected the message) works or just runs a computer that is losing power?

At first I thought that the CLIENT_ACKNOWLEDGE confirmation mode should save me, but obviously this is not so, Spring calls .acknowledge () no question what.

So, here is my question, how can I guarantee delivery? Using a custom MessageListenerContainer? Using transaction manager?

+3
source share
3 answers

Use a transactional session and indicate successful message processing by calling the Sessionclass method commit().

Mark section 19.4.5. Processing messages in transactions for configuration. (you can use DefaultMessageListenerContainer). Depending on what you do with the messages, you may need a JTA transaction manager.

+1
source

Spring message listener with Client_Acknowledge mode will acknowledge the message when the client calls message.acknowledge ().

, , spring , .

, spring , - , , . , spring , , , , .

Spring JMS onMessage. JMS ( ) .

0

Session.AUTO_ACKNOWLEDGE , .

A message is automatically recognized when it successfully returns from the receive () method. If the receiver uses the MessageListener of the interface, the message is automatically acknowledged when it successfully returns from onMessage (). If a failure occurs while receiving the () method or the onMessage () method, the message is automatically added. The JMS provider carefully manages re-delivery and guarantees the semantics of delivery only once.

-1
source

Source: https://habr.com/ru/post/1740794/


All Articles