com.ibm.mq.jms

Class MQMessageConsumer

  1. java.lang.Object
  2. extended bycom.ibm.mq.jms.MQRoot
  3. extended bycom.ibm.mq.jms.MQMessageConsumer
All implemented interfaces:
JmsMessageConsumer, JmsPropertyContext, JmsReadablePropertyContext, java.io.Serializable, java.util.Map<java.lang.String,java.lang.Object>, javax.jms.MessageConsumer
Direct known subclasses:
MQQueueReceiver, MQTopicSubscriber

  1. public class MQMessageConsumer
  2. extends MQRoot
  3. implements javax.jms.MessageConsumer, JmsMessageConsumer
MQMessageConsumer is the parent interface for all message consumers. A client uses a message consumer to receive messages from a destination.
See Also:
Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>

Method Summary

Modifier and Type Method and Description
  1. void
close()
Closes the message consumer.
  1. javax.jms.Destination
getDestination()
Gets the message destination.
  1. javax.jms.MessageListener
getMessageListener()
Gets the message consumer's message listener.
  1. java.lang.String
getMessageSelector()
Gets this message consumer's message selector expression.
  1. boolean
getNoLocal()
Indicates whether locally published messages are inhibited.
  1. javax.jms.Message
receive()
Receives the next message produced for this message consumer.
  1. javax.jms.Message
receive(long timeout)
Receives the next message that arrives within the specified timeout interval.
  1. javax.jms.Message
receiveNoWait()
Receives the next message if one is immediately available.
  1. void
setMessageListener(javax.jms.MessageListener listener)
Sets the message consumer's message listener.
Methods inherited from class com.ibm.mq.jms.MQRoot
clear, containsKey, containsValue, entrySet, equals, get, getBooleanProperty, getByteProperty, getBytesProperty, getCharProperty, getDoubleProperty, getFloatProperty, getIntProperty, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, hashCode, isEmpty, keySet, propertyExists, put, putAll, remove, setBatchProperties, setBooleanProperty, setByteProperty, setBytesProperty, setCharProperty, setDoubleProperty, setFloatProperty, setIntProperty, setLongProperty, setObjectProperty, setShortProperty, setStringProperty, size, values
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.ibm.msg.client.jms.JmsPropertyContext
setBatchProperties, setBooleanProperty, setByteProperty, setBytesProperty, setCharProperty, setDoubleProperty, setFloatProperty, setIntProperty, setLongProperty, setObjectProperty, setShortProperty, setStringProperty
Methods inherited from interface com.ibm.msg.client.jms.JmsReadablePropertyContext
getBooleanProperty, getByteProperty, getBytesProperty, getCharProperty, getDoubleProperty, getFloatProperty, getIntProperty, getLongProperty, getObjectProperty, getPropertyNames, getShortProperty, getStringProperty, propertyExists
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values

Method Detail

close

  1. public void close()
  2. throws javax.jms.JMSException
Closes the message consumer. Because a provider can allocate some resources outside the Java Virtual Machine on behalf of message consumers, clients must close them when they are not needed. You cannot rely on garbage collection to reclaim these resources eventually because this might not occur soon enough. This call blocks until a receive() or active message listener has completed.
Specified by:
close in interface javax.jms.MessageConsumer
Throws:
javax.jms.JMSException - if the operation fails.

getDestination

  1. public javax.jms.Destination getDestination( )
  2. throws javax.jms.JMSException
Gets the message destination.
Returns:
the destination - either queue or topic.
Throws:
javax.jms.JMSException - if the operation fails.

getMessageListener

  1. public javax.jms.MessageListener getMessageListener( )
  2. throws javax.jms.JMSException
Gets the message consumer's message listener.
Specified by:
getMessageListener in interface javax.jms.MessageConsumer
Returns:
the listener for the message consumer, or null if a listener is not set.
Throws:
javax.jms.JMSException - if the operation fails.

getMessageSelector

  1. public java.lang.String getMessageSelector( )
  2. throws javax.jms.JMSException
Gets this message consumer's message selector expression.
Specified by:
getMessageSelector in interface javax.jms.MessageConsumer
Returns:
this message consumer's message selector.
Throws:
javax.jms.JMSException - if the operation fails.

receive

  1. public javax.jms.Message receive( )
  2. throws javax.jms.JMSException
Receives the next message produced for this message consumer.

This call blocks indefinitely until a message is produced or until this message consumer is closed.

If this receive() is done within a transaction, the consumer retains the message until the transaction commits.

Specified by:
receive in interface javax.jms.MessageConsumer
Returns:
the next message produced for this message consumer, or null if this message consumer is concurrently closed
Throws:
javax.jms.JMSException - if the JMS provider fails to receive the next message due to an internal error.

receive

  1. public javax.jms.Message receive( long timeout)
  2. throws javax.jms.JMSException
Receives the next message that arrives within the specified timeout interval.

This call blocks until a message arrives, the timeout expires, or this message consumer is closed. A timeout of zero never expires, and the call blocks indefinitely.

Specified by:
receive in interface javax.jms.MessageConsumer
Parameters:
timeout - the timeout value (milliseconds)
Returns:
the next message produced for this message consumer, or null if the timeout expires, or this message consumer is concurrently closed
Throws:
javax.jms.JMSException - if the JMS provider fails to receive the next message due to an internal error.

receiveNoWait

  1. public javax.jms.Message receiveNoWait( )
  2. throws javax.jms.JMSException
Receives the next message if one is immediately available.
Specified by:
receiveNoWait in interface javax.jms.MessageConsumer
Returns:
the next message produced for this message consumer, or null if one is not available
Throws:
javax.jms.JMSException - if the JMS provider fails to receive the next message due to an internal error.

setMessageListener

  1. public void setMessageListener( javax.jms.MessageListener listener)
  2. throws javax.jms.JMSException
Sets the message consumer's message listener.
Specified by:
setMessageListener in interface javax.jms.MessageConsumer
Parameters:
listener - the messages are delivered to this listener.
Throws:
javax.jms.JMSException - if the operation fails.
See Also:
MessageConsumer.setMessageListener(javax.jms.MessageListener)

getNoLocal

  1. public boolean getNoLocal()
  2. throws javax.jms.JMSException
Indicates whether locally published messages are inhibited.
Specified by:
Returns:
set to true if locally published messages are being inhibited.
Throws:
javax.jms.JMSException