[TIBCO.EMS.UFOCLIENT .NET client library 7.0 documentation]

The message event handler for asynchronous message consumption.

Namespace:  TIBCO.EMS.UFO
Assembly:  TIBCO.EMS.UFO (in TIBCO.EMS.UFO.dll)

Syntax

public event EMSMessageHandler MessageHandler
Public Event MessageHandler As EMSMessageHandler
public:
 event EMSMessageHandler^ MessageHandler {
	void add (EMSMessageHandler^ value);
	void remove (EMSMessageHandler^ value);
}

Remarks

The client library raises an event when a message arrives at the destination. The program implements a handler delegate to processes it asynchronously.

The Delegate declaration for message event handler is as follows:
 Copy Code
            public delegate void EMSMessageHandler(object sender, EMSMessageEventArgs args);
            
sender: The source of the event. It can be either the MessageConsumer object or the Session object depending on to which object is the message handler registered.
args: The event argument, EMSMessageEventArgs

Examples

Example of using the message event handler:
 Copy Code
            ...
            consumer.MessageHandler += new EMSMessageHandler(handleMsg);
            ...
            private void handleMsg(object sender, EMSMessageEventArgs arg)
            {
               Message m = arg.Message;
               Console.WriteLine("Received message: " + m);
            }
            ...
            
User should either use MessageHandler or MessageListener to handle asynchronous message consumptions, but not both. Setting up both will cause the message to be handled more than once which can result in undefined behavior

Exceptions

ExceptionCondition
IllegalStateExceptionIf the consumer is closed

See Also