Search code examples
javaactivemq-classicapache-karafapache-servicemix

ActiveMQ enqueued message java servicemix karaf command


i m working with ActiveMQ ServiceMix and i want to have enqueued message count / dequeued message count etc... in java. i want value like it is showed in ActiveMQ Console

Name    Number Of Pending Messages      Number Of Consumers     Messages Enqueued       Messages Dequeued       Views       Operations  
Consumer.ID-10-147-244-247-15461c6c293-38-0.Vir...  0   2   13  13  
Consumer.ID-10-147-244-247-15470570c61-108-0.Vi...  0   2   13  13

I want to get Messages Enqueued columns :)

My program start a session with consumer and listener's. All work fine.

But for monitoring I have wrote a karaf command that call my subscription object (subscription containt session/connection/queue etc...)

In my subscription i try this :

ActiveMQConnection activeMQConnection = ((ActiveMQConnection) connection);
ActiveMQQueue activeMQQueue = getQueueConnection(queueName, activeMQConnection);

ActiveMQTopic a = AdvisorySupport.getConsumerAdvisoryTopic(activeMQQueue);

but next i don t know how to get DestinationStatistics to get all information about my queue/topic...

I try this too :

QueueBrowser queueBrowser = session.createBrowser(activeMQQueue);

but nothing interessting in browser.

if someone can help me to get my DestinationStatistics objetct ;)

thanks a lot


Solution

  • Finaly i use QueueBrowser to know length of the queue, QueuBrowser just browse the queue without remove them so i can iterate and count number of message in any queue.