Message acknowledgment
Every session that is not transacted has an acknowledgment mode that determines how messages received by the application are acknowledged. Three acknowledgment modes are available, and the choice of acknowledgment mode affects the design of the application.
The information in this topic is relevant only if an application connects to an IBM MQ queue manager or a WebSphere Application Server service integration bus. The information is not relevant for a real-time connection to a broker.
XMS uses the same mechanism for acknowledging the receipt of messages that JMS uses.
If a session is not transacted, the way that messages received by the application are acknowledged is determined by the acknowledgment mode of the session. The three acknowledgment modes are described in the following paragraphs:
- XMSC_AUTO_ACKNOWLEDGE
- The session automatically acknowledges each message received by
the application.
If messages are delivered synchronously to the application, the session acknowledges receipt of a message every time a Receive call completes successfully.
If the application receives a message successfully, but a failure prevents acknowledgment from occurring, the message becomes available for delivery again. The application must therefore be able to handle a message that is redelivered.
- XMSC_DUPS_OK_ACKNOWLEDGE
- The session acknowledges the messages received by the application
at times it selects.
Use 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. The application must therefore be able to handle messages that are redelivered.
- XMSC_CLIENT_ACKNOWLEDGE
- The application acknowledges the messages it receives by calling
the Acknowledge method of the Message class.
The application can acknowledge the receipt of each message individually, or it can receive a batch of messages and call the Acknowledge method only for the last message it receives. When the Acknowledge method is called all messages received since the last time the method was called are acknowledged.
In conjunction with any of these acknowledgment modes, an application can stop and restart the delivery of messages in a session by calling the Recover method of the Session class. Messages whose receipt was previously unacknowledged are redelivered. However, they might not be delivered in the same sequence in which they were previously delivered. In the meantime, higher priority messages might have arrived, and some of the original messages might have expired. In the point-to-point domain, some of the original messages might have been consumed by another application.
An application can determine whether a message is being re-delivered by examining the contents of the JMSRedelivered header field of the message. The application does this by calling the Get JMSRedelivered method of the Message class.
Parent topic: SessionsRelated concepts