public void send(final int n)
  {
    ActiveMQConnection connection = null;

    try
    {
      ActiveMQConnectionFactory cf =
        new ActiveMQConnectionFactory(Sender.BROKER_URL);
      connection = (ActiveMQConnection) cf.createConnection();
      
      connection.start();
      
      QueueSession session =
        connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      Queue queue         = session.createQueue(Sender.QUEUE_NAME);
      QueueSender sender  = session.createSender(queue);
      TextMessage message = session.createTextMessage();

      for (int i = 0; i < n; i++) {
        message.setText("This is message " + (i + 1));
        sender.send(message);
      }

      sender.send(session.createMessage());

    }
    catch (JMSException e)
    {
      e.printStackTrace();
    }
    finally {
      if (connection != null)
      {
        try
        {
          connection.close();
        }
        catch (JMSException e)
        {
          e.printStackTrace();
        }
      }
    }
  }