public void onMessage(Message m)
  {
    if (m instanceof TextMessage)
    {
      try
      {
        System.out.println("Message: " + ((TextMessage) m).getText());
      }
      catch (JMSException e)
      {
        e.printStackTrace();
      }
    }
    else if (connection != null)
    {
      try
      {
        connection.close();
      }
      catch (JMSException e)
      {
        e.printStackTrace();
      }
    }
  }