File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Duplicate JMS message processing with multiple MessageListener threads 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 "Duplicate JMS message processing with multiple MessageListener threads" Watch "Duplicate JMS message processing with multiple MessageListener threads" New topic
Author

Duplicate JMS message processing with multiple MessageListener threads

Haq Yunus
Ranch Hand

Joined: Apr 08, 2009
Posts: 42
I am creating a JMS listener application which listens on a queue. I am using TIBCO JMS
implementation and facing an issue that intermittently more than one of my listener threads
pick up a same message and that results in duplicate processing.

Here is how I am creating the connection:


Then here I am creating the listener threads with the same connection created above



Now here let us assume, 5 listener threads are created and they listen as receivers on a queue. I am seeing a behavior that
sometime more than one listener thread/receiver picks up the same message and I end up with duplicate processing? How can I
handle it through JMS configuration? Is it even possible? Or I would have to resort to some programmatic solution? Any advise
would be much appreciated. Thanks.

Cross-posted at:http://stackoverflow.com/questions/10191184/duplicate-message-processing-with-multiple-messagelistener-threads
Prabaharan Gopalan
Ranch Hand

Joined: Oct 16, 2009
Posts: 66

May be an obvious thing to ask: But I saw you specify 'Explicit client acknowledge'. But do all your listeners explicitly acknowledge the message reception once they are done? Easy way to check, is there a time difference between the message being processed by the first listener and the second one? Do you have the DUPS_OK_ACKNOWLEDGE setting on?

Googling doesn't make you a genius. But not Googling makes you dumber.
Haq Yunus
Ranch Hand

Joined: Apr 08, 2009
Posts: 42
Thanks.

Yes , listeners do acknowledge explicitly.

Easy way to check, is there a time difference between the message being processed by the first listener and the second one?
So for this I would have to maintain a map or some mechanism for common repository so listeners can check what message has been processed, right?

DUPS_OK_ACKNOWLEDGE is not on.
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

if you are opting for Client Acknowledge while creating Queue Session, the only reason i could see(there may be more) for multiple clients getting the message is the timeout for acknowlegment is less (or may be client is taking much time to acknowledge). Try increasing the timeout for this, atleast upto some value when your client can process the message & acknowledge back. hope that works.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Duplicate JMS message processing with multiple MessageListener threads
 
Similar Threads
JNDI Context problem
Trying to write a jms client to receive as message
JMS conceptual doubt
jdeveloper look up error for jms
jms pub sub