Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hold messages in JMS Message Queue if there are any error after consuming the message?

My scenario is - I post message in to queue and once message is consumed I am sending it to third party middleware application. If that middleware application is down then my posted message gone for toss. I do not want to lose that message if middleware application is down instead I want it to be on hold or waiting in the queue. Please suggest, how to handle this scenario?

like image 458
Dinesh M Avatar asked May 15 '15 18:05

Dinesh M


People also ask

Which one is responsible to hold the message until receiver is ready in JMS?

The Queue is responsible to hold the message until receiver is ready.

Which JMS messaging model to be used if multiple receivers are expected to consume the message?

The point-to-point model is used when you need to send a message to only one message consumer. Even though multiple consumers may be listening on the queue for the same message, only one of those consumer threads will receive the message.

What happens when JMS queue is full?

When the queue fills, nothing can put new messages to it. In WebSphere MQ the producing application then receives a return code indicating that the queue is full. If the application distinguishes between fatal and transient errors, it can stop and retry.


1 Answers

You should create the session like this:

Session session = connection.createSession(false,
                       Session.CLIENT_ACKNOWLEDGE);

when you try to deliver the message to your third party app:

  • If it's working you should acknoledge the message.

  • If it is down you should'nt acknwoledge it, this way the JMS provider will be able to rediliver it,and the message will not be lost. message.acknowledge();

Also, you can take a look at this: JMS AUTO_ACKNOWLEDGE when is it acknowledged?

like image 114
GionJh Avatar answered Sep 22 '22 16:09

GionJh