O'Reilly logo

Java Message Service by Richard Monson-Haefel, David A Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Message Acknowledgments

The message acknowledgment protocol is the key to guaranteed messaging, and support for acknowledgment is required by the semantics of the JMS API. This section provides an in-depth explanation of how the acknowledgment protocol works and its role in guaranteed messaging.

We will begin by examining the AUTO_ACKNOWLEDGE mode. We will revisit this discussion later as it pertains to CLIENT_ACKNOWLEDGE , DUPS_OK_ACKNOWLEDGE , and JMS transacted messages. An understanding of the basic concepts of AUTO_ACKNOWLEDGE will make it easy to grasp the fundamental concepts of the other modes.

The acknowledgment mode is set on a JMS provider when a Session is created:

tSession = 
   tConnect.createTopicSession(false, Session.CLIENT_ACKNOWLEDGE);

qSession =
   qConnect.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);

AUTO_ACKNOWLEDGE

We'll look at the AUTO_ACKNOWLEDGE mode from the perspective of a message producer, the message server, and the message consumer.

The producer's perspective

Under the covers, the TopicPublisher.publish( ) or QueueSender.send( ) methods are synchronous. These methods are responsible for sending the message and blocking until an acknowledgment is received from the message server. Once an acknowledgment has been received, the thread of execution resumes and the method returns; processing continues as normal. The underlying acknowledgment is not visible to the client programming model. If a failure condition occurs during this operation, an exception ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required