Progress
External Program
Interfaces
Message Acknowledgment and Recovery
A client sends an acknowledgement to tell the SonicMQ broker that the client received and processed a message and does not need to receive that message again. The acknowledgment of a message guarantees that the message and all previous messages are not delivered again to that session.
The following sections describe automatic message acknowledgment, preventing message acknowledgment, and message recovery.
Automatic Message Acknowledgement
With the 4GL–JMS API, an incoming message is acknowledged automatically when the message handler finishes execution. It is sent on the request for the next message, which helps performance.
If there is a client or communication failure between the time the message handler finishes execution and the time the 4GL–JMS implementation sends the acknowledgment, the message might be redelivered (according to the JMS message redelivery rules). An application can use a transacted session to avoid this message redelivery problem.
Unlike Java–JMS, the 4GL–JMS API does not support the explicit acknowledgment of messages or the “lazy” acknowledgment of messages (the CLIENT_ACKNOWLEDGE and DUPS_OK_ACKNOWLEDGE JMS modes).
Preventing Message Acknowledgment
A 4GL application can explicitly prevent the acknowledgment of a message by calling the setNoAcknowledge method of the messageConsumer. (The messageConsumer object is passed as a parameter to the message-handler procedure.) The setNoAcknowledge method is typically used when the application wants to receive the same message again due to some error in processing it or when it needs to acknowledge a group of messages by acknowledging only the last message in the group.
Single Message Acknowledgement
Normally, a 4GL client application automatically acknowledges a message when the message handler procedure completes. But in SINGLE_MESSAGE_ACKNOWLEDGE mode, each message requires its own acknowledgement, and if you choose to not acknowledge a message, the message is never acknowledged.
To turn on SINGLE_MESSAGE_ACKNOWLEDGE mode, a 4GL client application calls the setSingleMessageAcknowledgement() method of the session handle with the input parameter set to TRUE. To turn off this mode, the application calls the same method with the input parameter set to FALSE.
Message Recovery
If an application wants to again receive all the messages that were not acknowledged, it can call the recover procedure in the Session object. If recover is called on a stopped session (stopReceiveMessages was called), the session is recovered and message delivery is restarted.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |