Message delivery

XMS supports persistent and nonpersistent modes of message delivery, and asynchronous and synchronous delivery of messages.

Message delivery mode

XMS supports two modes of message delivery:
Persistent messages are delivered once. A messaging server takes special precautions, such as logging the messages, to ensure that persistent messages are not lost in transit, even in the event of a failure.
Nonpersistent messages are delivered no more than once. Nonpersistent messages are less reliable than persistent messages because they can be lost in transit in the event of a failure.

The choice of delivery mode is a trade-off between reliability and performance. Nonpersistent messages are typically transported more quickly than persistent messages.

Asynchronous message delivery

XMS uses one thread to handle all asynchronous message deliveries for a session. This means that only one message listener function or one onMessage() method can run at a time.

If more than one message consumer in a session is receiving messages asynchronously, and a message listener function or onMessage() method is delivering a message to a message consumer, then any other message consumers that are waiting for the same message must continue to wait. Other messages that are waiting to be delivered to the session must also continue to wait.

If an application requires concurrent delivery of messages, create more than one session so that XMS uses more than one thread to handle asynchronous message delivery. In this way, more than one message listener function or onMessage() method can run concurrently.

A session is not made asynchronous by assigning a message listener to a consumer. A session becomes asynchronous only when the Connection.Start method is called. All synchronous calls are permitted until the Connection.Start method is called. Message delivery to consumers start when the Connection.Start is called.

If synchronous calls, such as creation of a consumer or producer, must be made on an asynchronous session, the Connection.Stop must be called. A session can be resumed by calling the Connection.Start method to start delivery of messages. The only exception to this is the Session message delivery thread, which is the thread that delivers messages to the callback function. This thread can to make any call on session (except a Close call) in the message callback function.

Note: In Unmanaged mode, the MQDISC call within a call-back function is not supported by the IBM® MQ .NET client. So, the client application cannot Create or Close sessions within the MessageListener callback in Asynchronous receive mode. Create and dispose the session outside of the MessageListener method.

Synchronous message delivery

Messages are delivered synchronously to an application if the application uses the Receive methods of MessageConsumer objects.

Using the Receive methods, an application can wait a specified period of time for a message, or it can wait indefinitely. Alternatively, if an application does not want to wait for a message, it can use the Receive with No Wait method.