IMessageConsumer

An application uses a message consumer to receive messages sent to a destination.

    Inheritance hierarchy:
    IBM.XMS.IPropertyContext
       |
       +----IBM.XMS.IMessageConsumer
    

For a list of the XMS defined properties of a MessageConsumer object, see Properties of MessageConsumer.

Parent topic: .NET interfaces


.NET properties

    Summary of .NET properties:

    .NET property Description
    MessageListener Get the message listener that is registered with the message consumer, and register a message listener with the message consumer.
    MessageSelector Get the message selector for the message consumer.


MessageListener - Get and Set Message Listener

    Interface:
    MessageListener MessageListener
    {
      get;
      set;
    }
    

Get the message listener that is registered with the message consumer, and register a message listener with the message consumer.

If no message listener is registered with the message consumer, MessageListener is null. If a message listener is already registered with the message consumer, we can cancel the registration by specifying a null instead.

For more information about using message listeners, see Use message and exception listeners in .NET.

    Exceptions:

    • XMSException


MessageSelector - Get Message Selector

    Interface:
    String MessageSelector
    {
      get;
    }
    

Get the message selector for the message consumer. The return value is a String object encapsulating the message selector expression. If data conversion is required, this value is the message selector expression after conversion. If the message consumer does not have a message selector, the value of MessageSelector is a null String object.

    Exceptions:

    • XMSException


Methods

    Summary of methods:

    Method Description
    Close Close the message consumer.
    Receive Receive the next message for the message consumer. The call waits indefinitely for a message, or until the message consumer is closed.
    Receive Receive the next message for the message consumer. The call waits only a specified period for a message, or until the message consumer is closed.
    ReceiveNoWait Receive the next message for the message consumer if one is available immediately.


Close - Close Message Consumer

    Interface:
    void  Close();
    

Close the message consumer.

If an application tries to close a message consumer that is already closed, the call is ignored.

    Parameters:
    None

    Returns:
    Void

    Exceptions:

    • XMSException


Receive - Receive

    Interface:
    IMessage Receive();
    

Receive the next message for the message consumer. The call waits indefinitely for a message, or until the message consumer is closed.

    Parameters:
    None

    Returns:
    A pointer to the Message object. If the message consumer is closed while the call is waiting for a message, the method returns a pointer to a null Message object.

    Exceptions:

    • XMSException


Receive - Receive (with a wait interval)

    Interface:
    IMessage Receive(Int64 delay);
    

Receive the next message for the message consumer. The call waits only a specified period for a message, or until the message consumer is closed.

    Parameters:

      delay (input)
      The time, in milliseconds, that the call waits for a message. If you specify a wait interval of 0, the call waits indefinitely for a message.

    Returns:
    A pointer to the Message object. If no message arrives during the wait interval, or if the message consumer is closed while the call is waiting for a message, the method returns a pointer to a null Message object but throws no exception.

    Exceptions:

    • XMSException


ReceiveNoWait - Receive with No Wait

    Interface:
    IMessage ReceiveNoWait();
    

Receive the next message for the message consumer if one is available immediately.

    Parameters:
    None

    Returns:
    A pointer to a Message object. If no message is available immediately, the method returns a pointer to a null Message object.

    Exceptions:

    • XMSException


Inherited properties and methods

The following methods are inherited from the IPropertyContext interface: