• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Duplicate Messages in JMS  RSS feed

 
Ranch Hand
Posts: 370
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We are receiving some messages in JMS queues, so, wanted to understand how can we identify the duplicates JMS messages?
 
author
Sheriff
Posts: 23608
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is a side discussion... but... simply, if you are not using transactions, you are always responsible for duplicate detection.

In the case of queuing (if you don't use transactions), you get a message, you have to process the message, you have to tell the broker that you processed it, and finally, the broker confirming that it has been consumed. etc.... and ... somewhere between processing the message and the broker confirming that it has been processed, is the point where you want the message to be no longer delivered. Unfortunately, the actually point is where the broker confirms it (that it can survive a restart).

So, if you processed it to the point where you are okay with it, and the environment dies before it is confirmed, it will be redelivered on restart.... so... in other words, without transactions, you are responsible for duplicate detection.

Henry
 
Henry Wong
author
Sheriff
Posts: 23608
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

... but ... to answer your question...

Vaibhav Gargs wrote:how can we identify the duplicates JMS messages?



If you want it guaranteed, you can only do it by payload. It is your message, sent by your publishers/producers, and for your subscribers/consumers; so, only your application knows that the message has been processed. Now, you can argue that it can be done via sequence numbers, yadda yadda  yadda, but, keep in mind, that that means that your publisher can't double publish (and also, have restart mechanisms that guarantees never to republish).

Henry
 
Bartender
Posts: 2083
276
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Henry Wong wrote:If you want it guaranteed, you can only do it by payload.


Could the the JMSCorrelationID header be used for this if it wasn't already being used for other purposes?
 
Vaibhav Gargs
Ranch Hand
Posts: 370
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Henry and Ron.

Which acknowledgement mode we should be using for this case? And, suppose our application consumed the message successfully, and in the meanwhile, the broker gets restarted without having any acknowledgement, then, i believe it will redeliver the message, right? And, what will happen for non-persistent messages?

Should we persist the correlation ids somewhere in DB, and, will then check for every incoming message against the stored ones, but won't it be a big performance hit?
 
Henry Wong
author
Sheriff
Posts: 23608
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:
Could the the JMSCorrelationID header be used for this if it wasn't already being used for other purposes?



Using a header if fine too.... but regardless, to guarantee it, it is the responsibility of both the sending application and receiving application. It can't be done one sided.

Henry
 
Henry Wong
author
Sheriff
Posts: 23608
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vaibhav Gargs wrote:
Which acknowledgement mode we should be using for this case? And, suppose our application consumed the message successfully, and in the meanwhile, the broker gets restarted without having any acknowledgement, then, i believe it will redeliver the message, right? And, what will happen for non-persistent messages?



It is the responsibility of the receiver to detect duplicates (with some help from the sender). Depending on the configuration, the message may be redelivered, and you have to do dup detection.

Non persisted messages do not survive restarts...

Henry
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!