title: how to access the activemq statistics plugin in .net
body: <p>I am trying to access the activemq statistics information <a href="http://activemq.apache.org/statisticsplugin.html" rel="nofollow">http://activemq.apache.org/statisticsplugin.html</a> in c#</p>
  
  <p>This is what i have so far. I am not able to get a reply from the consumer. I can the count increase in monitor website for the queue.  </p>
  
  <pre><code>public class Statistics 
  {
      private readonly string queueName = string.Empty;
      private readonly string queueToMonitor = string.Empty; 
      private readonly IConnectionFactory connectionFactory;
      private readonly IConnection connection;
      private readonly ISession session;
      private readonly IMessageProducer producer;
      private readonly ActiveMQQueue queue;
  
  
      public Statistics(string qName, string brokerUri, string queueToMon)
      {
          this.queueName = qName;
          this.queueToMonitor = "ActiveMQ.Statistics.Destination." + queueToMon; 
          this.connectionFactory = new ConnectionFactory(brokerUri);
          this.connection = connectionFactory.CreateConnection();
          this.connection.Start();
          this.session = connection.CreateSession();
  
          queue = new ActiveMQQueue(qName);
          producer = session.CreateProducer(queue);
  
      }
  
      public void GetStats()
      {
          try
          {
              var statusQueue = session.CreateTemporaryQueue();
              var consumer = session.CreateConsumer(statusQueue);
              ActiveMQQueue query = new ActiveMQQueue(queueToMonitor);
  
              var msg = session.CreateMessage();
              msg.NMSReplyTo = statusQueue;
              producer.Send(queue, msg);
  
              var reply = (ActiveMQMapMessage)consumer.Receive();
  
              if (reply != null)
              {
                  var test = reply.Content.ToString(); 
              }
           }
          catch (Exception e)
          {
              var t = e.Message + " " + e.StackTrace;
          }
  
      }
  }
  </code></pre>