Message Delivery
A client can receive messages synchronously or asynchronously.
For synchronous receipt, a client can request the next message from a message consumer using one of its receive methods. Several variations of receive allow a client to poll or wait for the next message. receive() is a blocking method that blocks until the message arrives or times out.
For asynchronous receipt, a client can register a MessageListener object with a message consumer. As messages arrive at the message consumer, the client delivers them by calling the message listener's onMessage() method. The onMessage() method proceeds based on the contents of the message. You register the message listener with a specific message consumer using the setMessageListener() method.