Synchronous Versus Asynchronous Messaging

A client can be set up to synchronously or asynchronously receive messages. With synchronous delivery, a client can request the next message from a MessageConsumer by using one of the receive methods. Three different receive methods can be used:

  • receive— Receive the next message for this consumer

  • receive(long timeout)— Receive the next message that arrives within the timeout interval

  • receiveNoWait— Receive the next message if one is immediately available

A JMS consumer can also receive messages asynchronously. The client registers an object that implements the MessageListener interface with the JMS server. When messages arrive for a particular MessageConsumer that has a MessageListener registered, the ...

Get Special Edition Using Enterprise JavaBeans™ 2.0 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.