0

Is there a way in C# to do following

a) Connect to AMQ

b) Find All Queues

c) For each Queue, find the count of consumers and Id/Name of Consumer

d) For each Queue, find the count of produces and Id/Name of Producer

I have used NMS but it does not give me a way of finding Consumer count for a Queue or name of the consumer.

enter image description here

As you can see from the image, i have a queue and have 5 consumers connected to that queue. I need to be able to find the count and also the names.

Thanks, Zaeem

2 Answers2

0

Since C# applications won't be able to connect to the Broker's JMX monitoring features you are left with solutions that involve NMS API code and a bit of broker configuration. There are two features of the broker that should allow you to mostly figure out what you need, the first is Advisory Topics and the second is the Statistics Plugin feature.

With the advisory support enabled broker side your client could subscribe to the advisory Topic for Queue create / destroy and keep a cache of active destinations on the broker. Then you can use the query feature of the statistics plugin to query on the state of a given Queue as needed.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42
  • so im able to connect to AMQ but again i cannot find a way progamatically to find information about a existing queue and consumer on that queue. – user1535623 Jul 25 '17 at 17:19
  • Below is the code snippet i managed to find but this creates temp queue and a producer and consumer. All i want is to find existing queue information and its consumer count and Name [link]https://stackoverflow.com/questions/15746391/how-to-access-the-activemq-statistics-plugin-in-net?rq=1 – user1535623 Jul 25 '17 at 17:23
  • The code given is your only option, C# clients can't talk to JMX Mbeans so you have to use the statistics broker plugin feature to query for info on a destination. There's no other answer here, features don't appear as if by magic when you want them to. – Tim Bish Jul 25 '17 at 22:55
  • sorry im a bit new to c# and AMQ. do you know how to use statistics broker plugin to query that ? – user1535623 Jul 26 '17 at 13:26
0

I managed to get this done by calling the admin.bat file on AMQ Server in the end