A client using the simplified JMS API introduced for JMS 2.0 uses a {@code JMSConsumer} object to receive messages from a queue or topic. A{@code JMSConsumer} object may be created either created by passing a{@code Queue} or {@code Topic} object to one of the {@code createConsumer}methods on a {@code JMSContext}. or by passing a {@code Topic} object to oneof the {@code createSharedConsumer} or {@code createDurableConsumer} methodson a {@code JMSContext}.
A {@code JMSConsumer} can be created with a message selector. A messageselector allows the client to restrict the messages delivered to the {@code JMSConsumer} to those that match the selector.
A client may either synchronously receive a {@code JMSConsumer}'s messages or have the {@code JMSConsumer} asynchronously deliver them as they arrive.
For synchronous receipt, a client can request the next message from a {@code JMSConsumer} using one of its {@code receive} methods. There areseveral variations of {@code receive} that allow a client to poll or wait forthe next message.
For asynchronous delivery, a client can register a {@code MessageListener}object with a {@code JMSConsumer}. As messages arrive at the {@code JMSConsumer}, it delivers them by calling the {@code MessageListener}'s {@code onMessage} method.
It is a client programming error for a {@code MessageListener} to throw anexception.
@version 2.0
@see javax.jms.JMSContext