TIBCO Enterprise Message Service 4.3.0 .NET Client Class Library

MessageConsumer.MessageHandler Event

The message event handler for asynchronous message consumption.

public event EMSMessageHandler MessageHandler;

Event Data

The event handler receives an argument of type EMSMessageEventArgs containing data related to this event. The following EMSMessageEventArgs property provides information specific to this event.

Property Description
Message Get the Message which caused the event

Remarks

The Delegate declaration for message event handler is as follows:

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
Example of using the message event handler:
...
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
For complete details, see the corresponding item in the book TIBCO Enterprise Message Service .NET Reference.

Exceptions

Exception Type Condition
IllegalStateException If the consumer is closed

See Also

MessageConsumer Class | TIBCO.EMS Namespace