Name
MessageConsumer
Synopsis
A message consumer is used by JMS clients to receive messages. A
message consumer is created by a client by specifying a Destination
from which to receive messages, and an optional message selector that
filters messages according to their header fields and property
values. The methods for creating MessageConsumers
are defined in
subclasses of the Connection
interface.
A message selector is a filter string whose syntax is based on the SQL92 conditional expression syntax. More details on the syntax of message selectors can be found in chapter X, “Java Message Service”.
A client can use a MessageConsumer
synchronously, by polling it using
its receive methods, or asynchronously, by registering a
MessageListener
with the consumer. When a message arrives that matches
the sending Destination
and the message selector, then the onMessage()
method on the registered listener is called.
MessageConsumers
should be freed by calling their close()
method, to
free up any resources allocated for them by the provider.
public interface MessageConsumer { // Public Instance Methods public abstract void close() throws JMSException; public abstract MessageListener getMessageListener( ) throws JMSException; public abstract String getMessageSelector( ) throws JMSException; public abstract javax.jms.Message receive( ) throws JMSException; public abstract javax.jms.Message receive( long timeout) throws JMSException; public abstract javax.jms.Message receiveNoWait( ) throws JMSException; ...
Get Java Enterprise in a Nutshell, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.