Collapse All Expand All

.NET Framework Class Library
See Also

[TIBCO.EMS .NET client library 6.0 documentation]

Delegate declaration for message event handler

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

# Syntax

    public delegate void EMSMessageHandler(
    	Object sender,
    	EMSMessageEventArgs args
    )

    Public Delegate Sub EMSMessageHandler ( _
    	sender As Object, _
    	args As EMSMessageEventArgs _
    )

    public delegate void EMSMessageHandler(
    	Object^ sender,
    	EMSMessageEventArgs^ args
    )

#### Parameters

sender
  Type: System..::.Object
  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
  Type: TIBCO.EMS..::.EMSMessageEventArgs
  The event argument, EMSMessageEventArgs

# Remarks

This delegate provides an asynchronous pathway for receiving messages. The program implements this delegate, and registers it with a MessageConsumer. When a message arrives, the client library raises an event. This delegate processes the event, which presents the message.

The EMSMessageHandler receives messages in a .NET programming idiom. In contrast, IMessageListener mimics the way in which JMS provides similar functionality in a Java programming idiom. Programmers may select either idiom—but not both (which would cause duplicate message processing, with undefined behavior).

Example 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);
                   ...
                }
                ...

Serialization

In compliance with the JMS specification, sessions distribute messages to listeners and event handler delegates in serial (non-concurrent) fashion.

# See Also

TIBCO.EMS Namespace