XMS mq client_acknowledge - acknowledge separately messages

1k Views Asked by At

I'm trying to write MQ client which will be resistant to unexpected situation. I have created client with client_acknowledge mode:

ISession session = conn.CreateSession(false, AcknowledgeMode.ClientAcknowledge);

In the XMS documentation there is information for CLIENT_ACKNOWLEDGE:

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.

The client fetches for example 10 messages from queue and writes them to DB.

The question is how to setup this mode with acknowledge every single message ( for ensuring message delivery )?

1

There are 1 best solutions below

2
On

When a message is delivered to your application, how is it lost?

Since you are dealing with two resources, why not go for a transacted session or a XA transacted session. If there is an issue with updating DB, you could do a Rollback so that messages get redelivered.

Update

In a transacted session, acknowledge mode has no significance. Messages are acknowledged when a commit is called or rolled back when rollback is called.

If connection to IBM MQ queue manager is lost, all uncommitted messages are automatically rolled back by the queue manager. So no messages are lost.