how to access the activemq statistics plugin in .net

后端 未结 1 1860
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-23 15:53

I am trying to access the activemq statistics information http://activemq.apache.org/statisticsplugin.html in c#

This is what i have so far. I am not able to get a reply

相关标签:
1条回答
  • 2021-01-23 16:10

    You are sending the message to the wrong queue. You need to send the message to the ActiveMQ.Statistics.Destination.QueueToMonitor destination. I re-wrote your GetStats() function to show that it works. The critical change is which destination the producer sends the message to.

    public void GetStats()
    {
        try
        {
            IDestination statusQueue = session.CreateTemporaryQueue();
            IMessageConsumer consumer = session.CreateConsumer(statusQueue);
            IDestination query = session.GetQueue(queueToMonitor);
            IMessage msg = session.CreateMessage();
            IMessageProducer producer = session.CreateProducer(query);
    
            msg.NMSReplyTo = statusQueue;
            producer.Send(msg);
    
            IMapMessage reply = (IMapMessage) consumer.Receive();
    
            if(reply != null)
            {
                IPrimitiveMap statsMap = reply.Body;
    
                foreach(string statKey in statsMap.Keys)
                {
                    Console.WriteLine("{0} = {1}", statKey, statsMap[statKey]);
                }
            }
        }
        catch(Exception e)
        {
            var t = e.Message + " " + e.StackTrace;
        }
    }
    
    0 讨论(0)
提交回复
热议问题