If a C application registers a message listener function and context data with a message consumer, or if a C++ application registers a message listener with a message consumer, the application can receive messages asynchronously.
When a message arrives for a message consumer, XMS delivers the message to a C application by calling the message listener function, passing a pointer to the context data as one parameter and the handle for the message as the other parameter. XMS delivers the message to a C++ application by calling the onMessage() method of the message listener, passing a pointer to the message as a parameter.
XMS uses one thread to handle all asynchronous message delivery 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 currently delivering a message to one 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, it must 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.
For more information about using message listener functions in a C application, see Message listener functions in C. If you are using C++, see Message listeners in C++.