0

Using ActiveMQ once I read/consume a message from queue I want to redeliver the same message back to queue because I want to stop processing for a while. How can this be achieved?

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43

1 Answers1

0

To cancel unacknowledged messages back to the queue you can simply close your JMS consumer. If you're using AUTO_ACKNOWLEDGE mode on your JMS session you won't be able to cancel the messages back to the queue as they'll be acknowledged automatically.

If you're using a transacted JMS session you can simply call rollback() on the session.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
  • I am using DefaultMessageListenerContainer. DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setSessionTransacted(true); How can I call a rollback here? Can you pls help. – sstkoverflowcoder Nov 05 '20 at 06:53
  • How to rollback a transaction using the Spring JMS API is really a different question than the one you originally asked. I recommend you ask a *new* question about this and if my answer addressed your original question mark it as correct to help other users who may have this same question in the future. Thanks! – Justin Bertram Jan 21 '21 at 02:52