Simple Synchronous Receiver Example
The code for a simple synchronous receiver is very similar to that of the sender method already presented. There are two important differences.
The first one is obvious; a MessageConsumer is created instead of a MessageProducer. The Session.createConsumer() method throws a JMSException if the session fails to create a consumer, and an InvalidDestinationException if an invalid destination is specified.
The second difference is that this time there is a call to the connection's start() method, which starts (or restarts) delivery of incoming messages for this destination. Calling start() twice has no detrimental effect. It also has no effect on the connection's ability to send messages. The start() method may ...