This topic has not yet been written. The content below is from the topic description.
7.4. The code Here's the code for the example: First we'll create a JNDI initial context from which to lookup our JMS objects: InitialContect ic = new InitialContext(); Now we'll look up the connection factory: ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory"); And look up the Queue: Queue orderQueue = (Queue)ic.lookup("/queues/OrderQueue"); Next we create a JMS connection using the connection factory: Connection connection = cf.createConnection(); And we create a non transacted JMS Session, with AUTO_ACKNOWLEDGE acknowledge mode: Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); We create a MessageProducer that will send orders to the queue: MessageProducer producer = session.createProducer(orderQueue); And we create a MessageConsumer which will consume orders from the queue: MessageConsumer consumer = session.createConsumer(orderQueue); We make sure we start the connection, or delivery won't occur on it: connection.start(); We create a simple TextMessage and send it: TextMessage message = session.createTextMessage("This is an order"); producer.send(message); And we consume the message: TextMessage receivedMessage = (TextMessage)consumer.receive(); System.out.println("Got order: " + receivedMessage.getText()); It's as simple as that. For a wide range of working JMS examples please see the examples directory in the distribution.