activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timothy Bish <tabish...@gmail.com>
Subject Re: How to find consumers on an exiting ActiveMQ Queue in c#
Date Wed, 26 Jul 2017 16:05:39 GMT
On 07/26/2017 12:01 PM, zaeem wrote:
> Below snippets lets you list Queues on the broker,Topics but i need
> something similar to list consumers on Queues for that broker by just
> passing a Queue Name.

No such API exists outside JMX, you have to do the work using only 
advisories and statistics

>
>          public const string QUEUE_ADVISORY_DESTINATION =
> "ActiveMQ.Advisory.Queue";
>          public const string TOPIC_ADVISORY_DESTINATION =
> "ActiveMQ.Advisory.Topic";
>          public const string TEMPQUEUE_ADVISORY_DESTINATION =
> "ActiveMQ.Advisory.TempQueue";
>          public const string TEMPTOPIC_ADVISORY_DESTINATION =
> "ActiveMQ.Advisory.TempTopic";
>
>   private static void Enumerate(string destination, Action<DestinationInfo>
> action)
>          {
>              IDestination dest = _session.GetTopic(destination);
>              using (IMessageConsumer consumer =
> _session.CreateConsumer(dest))
>              {
>                  IMessage advisory;
>
>                  while ((advisory =
> consumer.Receive(TimeSpan.FromMinutes(2000))) != null)
>                  {
>                      ActiveMQMessage am = advisory as ActiveMQMessage;
>                      if (am != null & am.DataStructure != null)
>                      {
>                          DestinationInfo info = am.DataStructure as
> DestinationInfo;
>                          if (info != null)
>                          {
>                              action(info);
>                          }
>                      }
>                  }
>              }
>          }
>
>        
>
>          public static void EnumerateQueues()
>          {
>              Console.WriteLine("Listing all Queues on Broker:");
>              Enumerate(QUEUE_ADVISORY_DESTINATION, info =>
>                  Console.WriteLine("   Queue: " + info.Destination));
>              Console.WriteLine("Listing Complete.");
>          }
>
>          public static void EnumerateTopics()
>          {
>              Console.WriteLine("Listing all Topics on Broker:");
>              Enumerate(TOPIC_ADVISORY_DESTINATION, info =>
>                  Console.WriteLine("   Topic: " + info.Destination));
>              Console.WriteLine("Listing Complete.");
>
>          }
>
>          public static void EnumerateDestinations()
>          {
>              Console.WriteLine("Listing all Destinations on Broker:");
>              Enumerate(ALLDEST_ADVISORY_DESTINATION, info =>
>              {
>                  string destType = info.Destination.IsTopic ? "Topic" :
> "Qeue";
>                  destType = info.Destination.IsTemporary ? "Temporary" +
> destType : destType;
>                  Console.WriteLine("   " + destType + ": " +
> info.Destination);
>              });
>              Console.WriteLine("Listing Complete.");
>          }
>
>
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/How-to-find-consumers-on-an-existing-ActiveMQ-Queue-in-c-tp4728927p4728936.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

-- 
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/


Mime
View raw message