Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMS AUTO_ACKNOWLEDGE when is it acknowledged?

I have tried to google this, but have not been successful. If I am using AUTO_ACKNOWLEDGE, and I have a consumer client written in Java, when is the message acknowledged? I am using a MessageListener which contains an onMessage method. Is the acknowledgement sent back to the server before onMessage or after onMessage completes or at some other point? Thanks in advance for any help anyone is able to provide!

like image 651
Reid Mac Avatar asked Jul 26 '12 16:07

Reid Mac


People also ask

What is JMS Acknowledgement?

Acknowledgement is the way that a consumer informs the JMS provider that it has successfully received a message. On the producer side, the only notion of acknowledgement consists of a successful invocation of either the topic publishe's publish method or the queue sender's send method.

What is Dups_ok_acknowledge?

DUPS_OK_ACKNOWLEDGE. The session acknowledges the messages received by the application at times it selects. Using this acknowledgment mode reduces the amount of work the session must do, but a failure that prevents message acknowledgment might result in more than one message becoming available for delivery again.

What is transacted session in JMS?

A transacted session supports a single series of transactions. Each transaction groups a set of produced messages and a set of consumed messages into an atomic unit of work. In effect, transactions organize a session's input message stream and output message stream into series of atomic units.


2 Answers

Please check this one (Wayback Machine link used as article went offline since 2020)

With AUTO_ACKNOWLEDGE mode the acknowledgment is always the last thing to happen implicitly after the onMessage() handler returns. The client receiving the messages can get finer-grained control over the delivery of guaranteed messages by specifying the CLIENT_ACKNOWLEDGE mode on the consuming session.

The use of CLIENT_ACKNOWLEDGE allows the application to control when the acknowledgment is sent. For example, an application can acknowledge a message - thereby relieving the JMS provider of its duty - and perform further processing of the data represented by the message. The key to this is the acknowledge() method on the Message object, as shown in Listing 1.

The acknowledge() method informs the JMS provider that the message has been successfully received by the consumer. This method throws an exception to the client if a provider failure occurs during the acknowledgment process. The provider failure results in the message being retained by the JMS server for redelivery.

like image 136
Andrey Borisov Avatar answered Sep 21 '22 00:09

Andrey Borisov


CLIENT_ACKNOWLEDGE
With this acknowledgment mode, the client acknowledges a consumed message by calling the message's acknowledge method.

Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); ... msg = (TextMessage) consumer.receive(); //acknowledge msg.acknowledge(); 

AUTO_ACKNOWLEDGE
With this acknowledgment mode, the session automatically acknowledges a client's receipt of a message either when the session has successfully returned from a call to receive or when the message listener the session has called to process the message successfully returns.

Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE); 

source
Best example

like image 24
Premraj Avatar answered Sep 17 '22 00:09

Premraj