Message acknowledgement v42.7.3.1
Acknowledgement messages are controlled by the two arguments to the createSession()
and createQueueSession()
methods:
If the first argument is true, it indicates that the session mode is transacted, and the second argument is ignored. However, if the first argument is false, then the second argument comes into play, and the client can specify different acknowledgment modes.
These acknowledgment modes include:
- Session.AUTO_ACKNOWLEDGE
- Session.CLIENT_ACKNOWLEDGE
- Session.DUPS_OK_ACKNOWLEDGE
Transacted session
In transacted sessions, messages are both sent and received during a transaction. These messages are acknowledged by making an explicit call to commit()
. If rollback()
is called, all received messages are marked as not acknowledged.
A transacted session always has an active transaction. When a client calls the commit()
or rollback()
method, the current transaction is either committed or rolled back, and a new transaction is started.
This example shows how the transacted session works:
AUTO_ACKNOWLEDGE mode
If the first argument to createSession()
or createQueueSession()
is false and the second argument is Session.AUTO_ACKNOWLEDGE
, the messages are acknowledged automatically.
DUPS_OK_ACKNOWLEDGE mode
This mode instructs the session to lazily acknowledge the message and that it's okay if some messages are redelivered. However, in EDB JMS, this option is implemented the same way as Session.AUTO_ACKNOWLEDGE
, where messages are acknowledged automatically.
CLIENT_ACKNOWLEDGE mode
If the first argument to createSession()
or createQueueSession()
is false and the second argument is Session.CLIENT_ACKNOWLEDGE
, the messages are acknowledged when the client acknowledges the message by calling the acknowledge()
method on a message. Acknowledging happens at the session level, and acknowledging one message causes all the received messages to be acknowledged.
For example, if you send five messages and then receive the five messages, acknowledging the fifth message causes all five messages to be acknowledged.