You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Vuppala <ha...@gmail.com> on 2009/06/17 22:57:59 UTC

How to get first 100 messages in the queue into an array

I am using ActiveMQ-5.2.0.


I have a scenario like, Queue can have a lot more than 100,000 messages.
So, I am afraid I get OutOfMemory error if I tried to move them to a
different queue in a single shot.

I see method 'browse' on 'QueueView' class which returns all the messages in
the queue.

So, if I can read specified number of messages ( like first 100) into an
array and move them to a different queue and loop the same till queue gets
emptied.

Please help me how can I achieve this at the earliest possible as I am
running short of time.

I appreciate your help.
-- 
View this message in context: http://www.nabble.com/How-to-get-first-100-messages-in-the-queue-into-an-array-tp24081944p24081944.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to get first 100 messages in the queue into an array

Posted by Vuppala <ha...@gmail.com>.

Thanks for reply.
If I understand,
If I Increase memory usage to 500mb, it should handle even queue is
populated with 1 million messages.

As I said earlier, currently I am using browse method of queueviewMbean
class to get all the messages in an array and then moving them to another
queue.

please correct me if the logic could be refined better or my understanding
is wrong.

I appreciate your help.


bsnyder wrote:
> 
> On Wed, Jun 17, 2009 at 2:57 PM, Vuppala<ha...@gmail.com> wrote:
>>
>> I am using ActiveMQ-5.2.0.
>>
>>
>> I have a scenario like, Queue can have a lot more than 100,000 messages.
>> So, I am afraid I get OutOfMemory error if I tried to move them to a
>> different queue in a single shot.
> 
> How much memory is specified in the memoryUsage element in the
> conf/activemq.xml config file? If you're using the default of 20mb,
> you need to increase this. By default, the JVM in which ActiveMQ runs
> is given 512mb of memory, so you should raise the memoryUsage amount
> up to a maximum of that amount.
> 
>> I see method 'browse' on 'QueueView' class which returns all the messages
>> in
>> the queue.
>>
>> So, if I can read specified number of messages ( like first 100) into an
>> array and move them to a different queue and loop the same till queue
>> gets
>> emptied.
>>
>> Please help me how can I achieve this at the earliest possible as I am
>> running short of time.
>>
>> I appreciate your help.
> 
> Bruce
> -- 
> perl -e 'print
> unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
> );'
> 
> ActiveMQ in Action: http://bit.ly/2je6cQ
> Blog: http://bruceblog.org/
> Twitter: http://twitter.com/brucesnyder
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-get-first-100-messages-in-the-queue-into-an-array-tp24081944p24083684.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: How to get first 100 messages in the queue into an array

Posted by Bruce Snyder <br...@gmail.com>.
On Wed, Jun 17, 2009 at 2:57 PM, Vuppala<ha...@gmail.com> wrote:
>
> I am using ActiveMQ-5.2.0.
>
>
> I have a scenario like, Queue can have a lot more than 100,000 messages.
> So, I am afraid I get OutOfMemory error if I tried to move them to a
> different queue in a single shot.

How much memory is specified in the memoryUsage element in the
conf/activemq.xml config file? If you're using the default of 20mb,
you need to increase this. By default, the JVM in which ActiveMQ runs
is given 512mb of memory, so you should raise the memoryUsage amount
up to a maximum of that amount.

> I see method 'browse' on 'QueueView' class which returns all the messages in
> the queue.
>
> So, if I can read specified number of messages ( like first 100) into an
> array and move them to a different queue and loop the same till queue gets
> emptied.
>
> Please help me how can I achieve this at the earliest possible as I am
> running short of time.
>
> I appreciate your help.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

ActiveMQ in Action: http://bit.ly/2je6cQ
Blog: http://bruceblog.org/
Twitter: http://twitter.com/brucesnyder

Re: How to get first 100 messages in the queue into an array

Posted by Rob Davies <ra...@gmail.com>.
Well - the OOM must be a bug - will try it out on the latest
On 17 Jun 2009, at 21:57, Vuppala wrote:

>
> I am using ActiveMQ-5.2.0.
>
>
> I have a scenario like, Queue can have a lot more than 100,000  
> messages.
> So, I am afraid I get OutOfMemory error if I tried to move them to a
> different queue in a single shot.
>
> I see method 'browse' on 'QueueView' class which returns all the  
> messages in
> the queue.
>
> So, if I can read specified number of messages ( like first 100)  
> into an
> array and move them to a different queue and loop the same till  
> queue gets
> emptied.
>
> Please help me how can I achieve this at the earliest possible as I am
> running short of time.
>
> I appreciate your help.
> -- 
> View this message in context: http://www.nabble.com/How-to-get-first-100-messages-in-the-queue-into-an-array-tp24081944p24081944.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>