How to count the nomber of message received in a Queue?

Posted by Admin on 31-Jan-2011 08:33

Hello,

I would like to count the message number received in a Queue with java program. I can see this with the Sonic soft, in the metric. Do I have to use the IMetric interface or a queue Listener?

Thanks

All Replies

Posted by sk185050 on 31-Jan-2011 08:46

Look for the sonic management API,

Checkout

public interface IQueueData

If that works for you.

Posted by Admin on 31-Jan-2011 08:56

GetMessageCount() in IQueueData returns the number of messages currently held in the queue. I don't count every message.

Posted by sk185050 on 31-Jan-2011 09:46

It don't count each message, it gave the messages numbers, I tried this and it gave me the count of the message that was in there in the QUEUE at that point of time.

Try with this.

connector = CountMessage.getConnector("tcp://localhost:2506", "Administrator", "Administrator");

// create a proxy to the broker component

IBrokerProxy broker = CountMessage.getBrokerProxy(connector, "Domain1", "DomainManager", "MgmtBroker");

// get the queues

Object[] queues = broker.getQueues(null).toArray();

// list the queues and their message count

for (int i = 0; i

System.out.println(((IQueueData)queues[i]).getQueueName() + ", " + ((IQueueData)queues[i]).getMessageCount());

Posted by Admin on 31-Jan-2011 09:57

I don't want the message number in Queue but I want a listener which count the number message received.

Posted by sk185050 on 31-Jan-2011 11:36

manage the stateful object in the listener, and you can count the messages it processed since it started .

I am not sure, if that is what you are looking for.

Posted by rrudis on 31-Jan-2011 12:24

The queue.messages.DeliveredPerSecond and queue.messages.ReceivedPerSecond metrics are averaged over the broker-wide collection interval, so you are unlikely to get what you want via metrics.  What is the use case?

Posted by Admin on 01-Feb-2011 03:36

I want to create a java app for monitoring queues.

Posted by rrudis on 01-Feb-2011 07:29

Are there particular aspects you are looking to monitor - e.g. queue depth, queue content?

Posted by Admin on 01-Feb-2011 07:36

No, I want only to know the message count received.

This thread is closed