0

I receive all JMS messages from Queue1 all the time and trying to process it.
If I tried to process 5 times, and rolled back 5 times, I want ActiveMQ to put the message to a different queue for some period of time (e.g. 5 minutes).
How can I achieve that?

Kai
  • 38,985
  • 14
  • 88
  • 103
surlac
  • 2,961
  • 2
  • 22
  • 31

1 Answers1

1

You can add a custom property to the message - like RESUBMIT_TIMES, and increment that until 5 is reached. Read this : JMS

if 5 is reached move it to the 5minutesqueue, by setting another property there that has the current timestamp. For example:

  message.setStringProperty("TimeOfDispatch", LocalDate.now().toString("yyyy-MM-dd hh:MM:ss"));

Have yet another consumer on the 5minutesqueue that check if 5 minutes have passed(by checking current time with the time from the header)

Eugene
  • 117,005
  • 15
  • 201
  • 306
  • Thanks Eugene. It looks like I need to handle it from a client side, but the question is if I can handle moving a message that has JMSXDeliveryCount==5 from Queue1 to a Queue2 for a 5 minutes (afterwards move back to Queue1) on the side of ActiveMQ. Is it possible? – surlac Apr 23 '13 at 10:04
  • @surlac I do not know, but honestly I don't think that they have such a thing in place. It is up to you to code it – Eugene Apr 23 '13 at 10:12
  • ActiveMQ has ["deadLetterStrategy"](http://activemq.apache.org/message-redelivery-and-dlq-handling.html) configuration, it very close to what I need, but not exact match. – surlac Apr 23 '13 at 12:15