MessageConsumer consumer = session.createConsumer(distributedQueue);
   public void example() throws Exception   {      String destinationName = getDestinationJNDIName();      InitialContext ic = null;      Connection connection = null;      try      {         // Create a connection to the clustered messaging instance         ic = new InitialContext();         ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");         Queue distributedQueue = (Queue)ic.lookup(destinationName);         log("Distributed queue " + destinationName + " exists");         // When connecting to a messaging cluster, the ConnectionFactory has the capability of         // transparently creating physical connections to different cluster nodes, in a round         // robin fashion ...         connection = cf.createConnection();         connection.start();         // Send a message to the queue         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);         MessageProducer producer = session.createProducer(distributedQueue);         TextMessage message = session.createTextMessage("Hello!");         producer.send(message);         log("The message was successfully sent to the distributed queue");         // Kill the active node         killActiveNode();         Thread.sleep(30000); // TODO not necesare after we install the client valve         // Transparenty create a consumer and receive the message         MessageConsumer consumer = session.createConsumer(distributedQueue);         message = (TextMessage)consumer.receive(2000);         log("Received message: " + message.getText());         assertEquals("Hello!", message.getText());         displayProviderInfo(connection.getMetaData());      }      finally      {         if(ic != null)         {            try            {               ic.close();            }            catch(Exception e)            {               throw e;            }         }         try         {            if (connection != null)            {               connection.close();            }         }         catch(JMSException e)         {            log("Could not close connection " + connection + ", exception was " + e);            throw e;         }      }   }