File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Message pickup by JMS receiver 2 when receiver 1 freezes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Message pickup by JMS receiver 2 when receiver 1 freezes" Watch "Message pickup by JMS receiver 2 when receiver 1 freezes" New topic

Message pickup by JMS receiver 2 when receiver 1 freezes

Vijay Murkoth

Joined: Mar 21, 2008
Posts: 1
I would like to know if anyone has a solution for the following -
A JMS sender sends a message. JMS receiver 1 picks it up, but freezes or fails to send message acknowledgement in the required amount of time. Require a way to determine that receiver 1 is frozen or slow and enable pickup and processing of the message by receiver 2. I know that if receiver 1 crashes, the message is available for receiver 2 to pick up. What I would like to know is if there is any way for receiver 2 to pick up the message if receiver 1 happens to take a time longer than a given duration to process the message (due to some other issue with receiver 1).

Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3753

First off, messaging is inherently asynchronous, meaning you get ZERO guarantee when a message will be read and acted on. That said, you could set up your system to send messages to two queues (either explicitly in the message sender or using some server-level queue management), with receiver 1 on queue 1 and receiver 2 on queue 2. If 'somehow' receiver 2 detects receiver 1 has crashed he can then act on the message.

Keep in mind, redundancy is one thing, but if you are writing code that expects one receiver to fail, chances are your time would be better spent making sure it doesn't.

[OCA 8 Book] [Blog]
Amir Pourteymour
Ranch Hand

Joined: Mar 06, 2008
Posts: 45
Can you clarify this more?

Do you mean if receiver 1 picks up the message, but takes more than enough to process due to any failure or computation freeze on his side. Receivers 2 comes and pick up the message to process?

What about using a demand store in your application server side, where you store the status of every single message to the point they're computed 100%, and remove the status afterward. Then, you can have the option to inquiry anything over there. Any pending message, which is not processed yet.

(+) Simple to implement, very handy in different situations, easy to learn about any failure in your system and route to another receiver.

(-) If you have cluster of application server, you need to have either distributed instances of your demand store. This makes the tracking very complicated.
I agree. Here's the link:
subject: Message pickup by JMS receiver 2 when receiver 1 freezes
jQuery in Action, 3rd edition