Sun Java System Message Queue 4.3 Developer's Guide for C Clients

Callback Type for Asynchronous Message Consumption

When you call the MQCreateAsyncMessageConsumer() function or the MQCreateAsyncDurableMessageConsumer() function, you must pass the name of an MQMessageListenerFunc type callback function that is to be called when the consumer receives a message to the specified destination.

The MQMessageListenerFunc type has the following definition:


MQError (* MQMessageListenerFunc)(
                const MQSessionHandle  sessionHandle,
                const MQConsumerHandle  consumerHandle,
                MQMessageHandle  messageHandle
                void * callbackData);

Parameters

sessionHandle

The handle to the session to which this consumer belongs. The client runtime specifies this handle when it calls your message listener.

consumerHandle

A handle to the consumer receiving the message. The client runtime specifies this handle when it calls your message listener.

messageHandle

A handle to the incoming message. The client runtime specifies this handle when it calls your message listener.

callbackData

The void pointer that you passed to the function MQCreateAsyncMessageConsumer or the function MQCreateAsyncDurableMessageConsumer.

The body of a message listener function is written by the receiving client. Mainly, the function needs to process the incoming message by examining its header, body, and properties. The client is also responsible for freeing the message handle (either from within the handler or from outside the handler) by calling MQFreeMessage.

In addition, you should observe the following guidelines when writing the message listener function: