WebSphere MQ Everyplace allows an application to listen for events occurring on queues. The application is able to specify message filters to identify the messages in which it is interested. A message arriving on queue triggers an event.
The Application example Ex 4 contains an example of using message listeners.
To enable this, an MQeMessageListener object must be created. The new() function for this takes an extra parameter, which is a function pointer. This function pointer indicates the function that should be called when a message arrives on the queue. This function should have the prototype:
- MQEVOID messageArrived(MQeMessageEventHndl hE);
Where MQeMessageEventHndl is a handle to an object that contains information about the message that has arrived. The queue needs to be aware of this handle , so the mqeQueueManager_addMessageListener function must be called with the MQeMessageListener object handle.
The MQeMessageEvent contains information about the message including:
Message filters only work on local queues. A separate technique known as message polling allows messages to be obtained as soon as they arrive on remote queues. (This is discussed in the next section.)