aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes JMS: Use of acknowledgment mode when posting a message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JMS: Use of acknowledgment mode when posting a message" Watch "JMS: Use of acknowledgment mode when posting a message" New topic
Author

JMS: Use of acknowledgment mode when posting a message

Stanley Walker
Ranch Hand

Joined: Sep 23, 2009
Posts: 87
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

Joined: Mar 07, 2007
Posts: 1280

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

Joined: Sep 23, 2009
Posts: 87
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

Joined: Mar 07, 2007
Posts: 1280

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

Joined: Sep 23, 2009
Posts: 87
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JMS: Use of acknowledgment mode when posting a message