Package jakarta.jms

Interface JMSConsumer

All Superinterfaces:
AutoCloseable

public interface JMSConsumer extends AutoCloseable
A client using the simplified Jakarta Messaging API introduced for Jakarta Messaging 2.0 uses a JMSConsumer object to receive messages from a queue or topic. A JMSConsumer object may be created either created by passing a Queue or Topic object to one of the createConsumer methods on a JMSContext. or by passing a Topic object to one of the createSharedConsumer or createDurableConsumer methods on a JMSContext.

A JMSConsumer can be created with a message selector. A message selector allows the client to restrict the messages delivered to the JMSConsumer to those that match the selector.

A client may either synchronously receive a JMSConsumer's messages or have the JMSConsumer asynchronously deliver them as they arrive.

For synchronous receipt, a client can request the next message from a JMSConsumer using one of its receive methods. There are several variations of receive that allow a client to poll or wait for the next message.

For asynchronous delivery, a client can register a MessageListener object with a JMSConsumer. As messages arrive at the JMSConsumer, it delivers them by calling the MessageListener 's onMessage method.

It is a client programming error for a MessageListener to throw an exception.

Since:
JMS 2.0
Version:
Jakarta Messaging 2.0
See Also: