MessageConsumer


public interface MessageConsumer
Subinterfaces: QueueReceiver and TopicSubscriber

WebSphere MQ class: MQMessageConsumer



java.lang.Object
   |
   +----com.ibm.mq.jms.MQMessageConsumer

The parent interface for all message consumers.
A client uses a message consumer to receive messages from a Destination.

Methods

getMessageListener
public MessageListener getMessageListener()
                                      throws JMSException

Get the message consumer's MessageListener.

Returns:
the listener for the message consumer, or null if a listener is not set.

Throws:
JMSException - if JMS fails to get the message listener because of a JMS error.

See also:
setMessageListener

getMessageSelector
public java.lang.String getMessageSelector()
                                throws JMSException

Get this message consumer's message selector expression.

Returns:
this message consumer's message selector.

Throws:
JMSException - if JMS fails to get the message selector because of a JMS error.

receive
public Message receive() throws JMSException

Receive the next message produced for this message consumer.

Returns:
the next message produced for this message consumer.

Throws:
JMSException - if JMS fails to receive the next message because of an error.

receive
public Message receive(long timeOut) throws JMSException

Receive the next message that arrives within the specified timeout interval. A timeout value of zero causes the call to wait indefinitely until a message arrives.

Parameters:
timeout - the timeout value (in milliseconds).

Returns:
the next message produced for this message consumer, or null if one is not available.

Throws:
JMSException - if JMS fails to receive the next message because of an error.

receiveNoWait
public Message receiveNoWait() throws JMSException

Receive the next message if one is immediately available.

Returns:
the next message produced for this message consumer, or null if one is not available.

Throws:
JMSException - if JMS fails to receive the next message because of an error.

setMessageListener
public void setMessageListener(MessageListener listener)
                                             throws JMSException

Set the message consumer's MessageListener.

Parameters:
messageListener - the messages are delivered to this listener.

Throws:
JMSException - if JMS fails to set message listener because of a JMS error.

See also:
getMessageListener

close
public void close() throws JMSException

Because a provider may allocate some resources outside of the JVM on behalf of a MessageConsumer, clients should close them when they are not needed. You cannot rely on garbage collection to reclaim these resources eventually, because this may not occur soon enough.

This call blocks until a receive or message listener in progress has completed.

Throws:
JMSException - if JMS fails to close the consumer because of an error.



© IBM Corporation 1997, 2002. All Rights Reserved