2

I have a consumer of a JMS queue. An exception may occur during the consumption, and I need to trigger the process again. I have two preliminary plans:

  1. Set acknowledge to javax.jms.Session.CLIENT_ACKNOWLEDGE. javax.jms.Message#acknowledge() is called to delete the message when processing succeeds, and javax.jms.Session#recover() is called to tell OpenMQ to redeliver the message when processing fails. But I couldn't find a way to set the maximum number of redeliveries and the time interval between redeliveries.

  2. Set acknowledge to javax.jms.Session.AUTO_ACKNOWLEDGE. Send a new message (containing the original message and the processing times) to a new queue each time an exception occurs, and I want to be able to set the delay time. However, I can't find a way to set the delay time of the message.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
winston
  • 37
  • 6
  • For option #2 you could look at the JMS 2.0 delayed delivery feature, just put back to the same queue with a delay. IBM MQ JMS implements a poison message feature where if the backout count of the message exceeds a threshold, the message will be moved to a backout queue, i don't know if OpenMQ implements something similar. – JoshMc Mar 15 '20 at 04:07
  • I've implemented delay message through OpenMQ. I started with a dependency package: `com.sun.messaging.mq:imq:4.6-b01`which did not implement the JMS2.0 API, and then found another dependency package `org.glassfish.mq:imq:5.1` based on your comment. Do you know why he changed the group id? @JoshMc – winston Mar 16 '20 at 11:02

0 Answers0