public void receive()
  {
    ActiveMQConnection connection = null;

    try
    {
      BrokerService broker = BrokerFactory.createBroker(
          "broker:(" + BROKER_URL + ")?" + BROKER_PROPS);

      broker.start();

      ActiveMQConnectionFactory cf =
        new ActiveMQConnectionFactory(Subscriber.BROKER_URL);
      connection = (ActiveMQConnection) cf.createConnection();
      
      connection.start();
      
      TopicSession session =
        connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);

      Topic topic = session.createTopic(TOPIC_NAME);
      TopicSubscriber subscriber = session.createSubscriber(topic);

      while (true)
      {
        Message message = subscriber.receive();

        if (message instanceof TextMessage)
          System.out.println("Message: " + ((TextMessage) message).getText());
        else break;
      }
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    finally {
      if (connection != null)
      {
        try
        {
          connection.close();
        }
        catch (JMSException e)
        {
          e.printStackTrace();
        }
      }
    }
  }