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 message 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 ...
Get Java Message Service, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.