Message Receiver
Following is the code used to create the messaging objects in the receiver application:
conn = factory.createConnection();
Session session = conn.createSession(false,
Session.AUTO_ACKNOWLEDGE);
MessageConsumer receiver = session.createConsumer(destination);
You define the connection and session objects the same as for the message sender application. However, the message receiver defines a message consumer rather than a message producer. The message consumer is created calling createConsumer() on the session.