Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

duplicate messages JMS

 
Preet Prasannan.
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I had a doubt. Is it possible that due to any circumstance, can a queue send multiple messages to the listener.
Or that by any chance, a duplicate message is posted to the queue and the same message is processed twice?
On a broader outlook, my question is that can there be a scenario due to which there can be duplication of a message in JMS(due to queue being hung or any other reason)?

 
Karthik Shiraly
Bartender
Posts: 1210
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Preet,

Yes it's possible. JMS providers have a retry concept. If registered subscribers are not reachable, then message sending is retried a number of times with delays inbetween them. Retry also occurs if the session specifies CLIENT_ACKNOWLEDGE but the subscriber fails to acknowledge a message.

Cheers
Karthik
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read: KeepItDown

I have removed the all uppercase subject for you.
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A duplicate message is not a retry message. There is a subtle and important difference.

As has been correctly pointed out, retry means that the message processor (A Listener or an MDB) did not either receive the message or did receive the message but failed to process it (due to some reason). In this case, the processor did not wilfully acknowledge the message forcing the container to redeliver it. This is part of the 'guaranteed messaging' principle offered by jms.

Duplicate messages on the other hand is an erroneous situation that needs to be guarded against in the message processor logic. With duplicate messages, the same message is delivered multiple times . This may happen due to a communication break down after processing but just before acknowledgement.

ram.
 
Kapil Raju
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a similar problem,

In our application we have an API which goes asynchronous after some point of time. Once it becomes asynchronous it goes to queue as a JMS message.

Now what has happened recently in our production environment is, the API got executed on 31st March and it has put a message to the queue, now that message for some reason didn't got executed. After 2 days the server got restarted and the message got executed twice.

So my question is,

Why the message didn't got executed? and for what reason it got executed after restart? and why twice?

Your inputs on this will be of great help in analyzing this issue.

Regards,
Kapil
 
ramprasad madathil
Ranch Hand
Posts: 489
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Please read Use One Thread Per Question

You have to provide some more information. How do you know the message was not delivered? It's more probable that it got delivered and was not acknowledged or else the acknowledgement failed. What kind of acknowledgement do you use? What is the Message Listener? An MDB?

ram.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!