Class ActiveMQMessageConsumer
- All Implemented Interfaces:
MessageConsumer,QueueReceiver,TopicSubscriber,AutoCloseable
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedActiveMQMessageConsumer(ConnectionFactoryOptions options, ActiveMQConnection connection, ActiveMQSession session, ClientConsumer consumer, boolean noLocal, ActiveMQDestination destination, String selector, SimpleString autoDeleteQueueName) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the message consumer.Gets theMessageConsumer'sMessageListener.Gets this message consumer's message selector expression.booleanGets theNoLocalattribute for this subscriber.getQueue()Gets theQueueassociated with this queue receiver.getTopic()Gets theTopicassociated with this subscriber.booleanisClosed()receive()Receives the next message produced for this message consumer.receive(long timeout) Receives the next message that arrives within the specified timeout interval.Receives the next message if one is immediately available.voidsetMessageListener(MessageListener listener) Sets theMessageConsumer'sMessageListener.toString()
-
Constructor Details
-
ActiveMQMessageConsumer
protected ActiveMQMessageConsumer(ConnectionFactoryOptions options, ActiveMQConnection connection, ActiveMQSession session, ClientConsumer consumer, boolean noLocal, ActiveMQDestination destination, String selector, SimpleString autoDeleteQueueName) throws JMSException - Throws:
JMSException
-
-
Method Details
-
getMessageSelector
Description copied from interface:MessageConsumerGets this message consumer's message selector expression.- Specified by:
getMessageSelectorin interfaceMessageConsumer- Returns:
- this message consumer's message selector, or null if no message selector exists for the message consumer (that is, if the message selector was not set or was set to null or the empty string)
- Throws:
JMSException- if the Jakarta Messaging provider fails to get the message selector due to some internal error.
-
getMessageListener
Description copied from interface:MessageConsumerGets theMessageConsumer'sMessageListener.This method must not be used in a Jakarta EE web or EJB application. Doing so may cause a
JMSExceptionto be thrown though this is not guaranteed.- Specified by:
getMessageListenerin interfaceMessageConsumer- Returns:
- the
MessageConsumer'sMessageListener, or null if one was not set - Throws:
JMSException- if the Jakarta Messaging provider fails to get theMessageListenerfor one of the following reasons:- an internal error has occurred or
- this method has been called in a Jakarta EE web or EJB application (though it is not guaranteed that an exception is thrown in this case)
- See Also:
-
setMessageListener
Description copied from interface:MessageConsumerSets theMessageConsumer'sMessageListener.Setting the the
MessageListenerto null is the equivalent of unsetting theMessageListenerfor theMessageConsumer.The effect of calling this method while messages are being consumed by an existing listener or the
MessageConsumeris being used to consume messages synchronously is undefined.This method must not be used in a Jakarta EE web or EJB application. Doing so may cause a
JMSExceptionto be thrown though this is not guaranteed.- Specified by:
setMessageListenerin interfaceMessageConsumer- Parameters:
listener- the listener to which the messages are to be delivered- Throws:
JMSException- if the Jakarta Messaging provider fails to set theMessageConsumer'sMessageListenerfor one of the following reasons:- an internal error has occurred or
- this method has been called in a Jakarta EE web or EJB application (though it is not guaranteed that an exception is thrown in this case)
- See Also:
-
receive
Description copied from interface:MessageConsumerReceives 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
receiveis done within a transaction, the consumer retains the message until the transaction commits.- Specified by:
receivein interfaceMessageConsumer- Returns:
- the next message produced for this message consumer, or null if this message consumer is concurrently closed
- Throws:
JMSException- if the Jakarta Messaging provider fails to receive the next message due to some internal error.
-
receive
Description copied from interface:MessageConsumerReceives 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
timeoutof zero never expires, and the call blocks indefinitely.- Specified by:
receivein interfaceMessageConsumer- Parameters:
timeout- the timeout value (in milliseconds)- Returns:
- the next message produced for this message consumer, or null if the timeout expires or this message consumer is concurrently closed
- Throws:
JMSException- if the Jakarta Messaging provider fails to receive the next message due to some internal error.
-
receiveNoWait
Description copied from interface:MessageConsumerReceives the next message if one is immediately available.- Specified by:
receiveNoWaitin interfaceMessageConsumer- Returns:
- the next message produced for this message consumer, or null if one is not available
- Throws:
JMSException- if the Jakarta Messaging provider fails to receive the next message due to some internal error.
-
close
Description copied from interface:MessageConsumerCloses the message consumer.Since a provider may allocate some resources on behalf of a
MessageConsumeroutside the Java virtual machine, clients should close them when they are not needed. Relying on garbage collection to eventually reclaim these resources may not be timely enough.This call will block until a
receivecall in progress on this consumer has completed. A blockedreceivecall returns null when this message consumer is closed.If this method is called whilst a message listener is in progress in another thread then it will block until the message listener has completed.
This method may be called from a message listener's
onMessagemethod on its own consumer. After this method returns theonMessagemethod will be allowed to complete normally.This method is the only
MessageConsumermethod that can be called concurrently.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceMessageConsumer- Throws:
JMSException- if the Jakarta Messaging provider fails to close the consumer due to some internal error.
-
getAutoDeleteQueueName
-
getQueue
Description copied from interface:QueueReceiverGets theQueueassociated with this queue receiver.- Specified by:
getQueuein interfaceQueueReceiver- Returns:
- this receiver's
Queue - Throws:
JMSException- if the Jakarta Messaging provider fails to get the queue for this queue receiver due to some internal error.
-
getTopic
Description copied from interface:TopicSubscriberGets theTopicassociated with this subscriber.- Specified by:
getTopicin interfaceTopicSubscriber- Returns:
- this subscriber's
Topic - Throws:
JMSException- if the Jakarta Messaging provider fails to get the topic for this topic subscriber due to some internal error.
-
getNoLocal
Description copied from interface:TopicSubscriberGets theNoLocalattribute for this subscriber. The default value for this attribute is false.- Specified by:
getNoLocalin interfaceTopicSubscriber- Returns:
- true if locally published messages are being inhibited
- Throws:
JMSException- if the Jakarta Messaging provider fails to get theNoLocalattribute for this topic subscriber due to some internal error.
-
toString
-
isClosed
public boolean isClosed()
-