You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by sreekar <tr...@gmail.com> on 2012/04/12 14:47:02 UTC

Check for pending queue messages...?

Hi Guys,

In Active-MQ CMS, is there any direct way to know the number of messages
ready-to-be-consumed ?

Currently, i found the following when searching in the CPP code:
--------------------------------------------------
int ActiveMQConsumer::getMessageAvailableCount() const {
    return this->internal->unconsumedMessages->size();
}
--------------------------------------------------

I guess this is the count of msgs-ready-to-be-consumed of a particular
session 
(with which ActiveMQConsumer is created).....right ?

If i want a total count of the messages in the queue, i am thinking of the
following:
[[ I have a map of all the producers that are sending messages to a queue ]]
-> create a temporary ActiveMQConsumer. (using the session with which
producer is created)
-> call above function, get size (accumulate with prev. count)
-> destroy the ActiveMQConsumer
-> repeat above 3 steps  for all producers.

Is there any better (efficient) way to get the message-count (enqueued but
not dequeued) from C++ API ?

bool ActiveMQQueueBrowser::hasMoreMessages()
{  
   ...
               if( this->browser->getMessageAvailableCount() > 0 ) {
                return true;
            }
   ...
}

ActiveMQQueueBrowser also seems to send TRUE/FALSE on a per session basis.


In the web-console, when i run the examples, i can see the count of, number
of messages-enqueued and number of messages dequeued.

I guess there might be some variable/function-call from where it is getting
those values, which i am currently not able to figure out.

Can anyone help me regards this.....i.e...to get the  count =
(messages_enqueued - message_dequeued) from within C++ API ?

[[ The code flow varies based upon this.......i.e whenever the count >
(prefetch_limit...or...Q_size_set) ]]

Any help would be appreciable.

Thanks & Regards,
Sreekar

--
View this message in context: http://activemq.2283324.n4.nabble.com/Check-for-pending-queue-messages-tp4551751p4551751.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Check for pending queue messages...?

Posted by sreekar <tr...@gmail.com>.
Hi Tim,

Thank you for the info.

The statistics plugin is cool.

I would like to go with it compared to "Advisory Messages".

Advisory-Message is like little extra info being delivered along with normal
messages right ?

I would like to send a separate message to get the statistics whenever
needed.

There is no Advisory message to get queue_statistics directly.

------------------------------------------------------------------------
Currently we have advisory messages that support

    consumers, producers and connections starting and stopping
    temporary destinations being created and destroyed
    messages expiring on topics and queues
    brokers sending messages to destinations with no consumers.
    connections starting and stopping
------------------------------------------------------------------------

Its good to know.

Previously also i looked at them but could not acknowledge them until i
found their necessity.

Thank you for the response.


Thanks & Regards,
Sreekar



--
View this message in context: http://activemq.2283324.n4.nabble.com/Check-for-pending-queue-messages-tp4551751p4552120.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Check for pending queue messages...?

Posted by Timothy Bish <ta...@gmail.com>.
On Thu, 2012-04-12 at 05:47 -0700, sreekar wrote: 
> Hi Guys,
> 
> In Active-MQ CMS, is there any direct way to know the number of messages
> ready-to-be-consumed ?
> 
> Currently, i found the following when searching in the CPP code:
> --------------------------------------------------
> int ActiveMQConsumer::getMessageAvailableCount() const {
>     return this->internal->unconsumedMessages->size();
> }
> --------------------------------------------------
> 
> I guess this is the count of msgs-ready-to-be-consumed of a particular
> session 
> (with which ActiveMQConsumer is created).....right ?
> 
> If i want a total count of the messages in the queue, i am thinking of the
> following:
> [[ I have a map of all the producers that are sending messages to a queue ]]
> -> create a temporary ActiveMQConsumer. (using the session with which
> producer is created)
> -> call above function, get size (accumulate with prev. count)
> -> destroy the ActiveMQConsumer
> -> repeat above 3 steps  for all producers.
> 
> Is there any better (efficient) way to get the message-count (enqueued but
> not dequeued) from C++ API ?
> 
> bool ActiveMQQueueBrowser::hasMoreMessages()
> {  
>    ...
>                if( this->browser->getMessageAvailableCount() > 0 ) {
>                 return true;
>             }
>    ...
> }
> 
> ActiveMQQueueBrowser also seems to send TRUE/FALSE on a per session basis.
> 
> 
> In the web-console, when i run the examples, i can see the count of, number
> of messages-enqueued and number of messages dequeued.
> 
> I guess there might be some variable/function-call from where it is getting
> those values, which i am currently not able to figure out.
> 
> Can anyone help me regards this.....i.e...to get the  count =
> (messages_enqueued - message_dequeued) from within C++ API ?
> 
> [[ The code flow varies based upon this.......i.e whenever the count >
> (prefetch_limit...or...Q_size_set) ]]
> 
> Any help would be appreciable.
> 
> Thanks & Regards,
> Sreekar
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Check-for-pending-queue-messages-tp4551751p4551751.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.

One way to get Broker side info in CMS is to use the
StatisticsBrokerPlugin, see:
http://activemq.apache.org/statisticsplugin.html

You can also use Advisories to collect some information from the Broker:
http://activemq.apache.org/advisory-message.html 

-- 
Tim Bish
Sr Software Engineer | FuseSource Corp
tim.bish@fusesource.com | www.fusesource.com
skype: tabish121 | twitter: @tabish121
blog: http://timbish.blogspot.com/