Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JMS: Use of acknowledgment mode when posting a message

 
Stanley Walker
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

for the last two days i have been reading quite a bit of acknowledgement mode for JMS. I understood that is required for a message to be acknowledged for its consumption to be completed.

however i do not understand what is the use of setting acknowledgement mode when we are simply posting a message to a queue.

Can someone please help?
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Stanley,

when you create a JMS Session the API requires the parameters "transacted" and "acknowledge mode" because Sessions can be used for both message producers and consumers. But the acknowledge mode only makes sense for message consumers. If the Session is created in an transactional context the acknowledge mode is ignored completely, but you still have to specify a value for it. So I'd say the JMS API is just not as clean as it could be for this part.

Marco
 
Stanley Walker
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Marco.
So i guess unless the same session is being used to post and consume the message, while posting messages to a queue acknowledgement mode is simply ignored even though API requires us to set it.
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, exactly ;-) If the send() method for a producer returns without errors the JMS broker already has received a message. It wouldn't make sense to additionally acknowledge it. In contrast for consumers acknowledge mode (or transaction handling) is important because it signals the message broker that the client has consumed a message correctly so that the broker can delete it from the queue.

Marco
 
Stanley Walker
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marco Ehrentreich wrote:In contrast for consumers acknowledge mode (or transaction handling) is important because it signals the message broker that the client has consumed a message correctly so that the broker can delete it from the queue.

Marco


now makes perfect sense
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic