thonnor
thonnor

Reputation: 1246

ActiveMQ - Controlling how many messages are consumed at a time.

Apologies for the wording of my question.

I am using Tomee.

I have an ActiveMQ queue set up and receiving messages from a Producer (the Tomee provided example)

It is persisted in MySQL (in case that matters)

My scenario is this...

At anyone time I could have 5 messages to process or 500+ (and anything in between)

Ideally, I would like some Java/Apache library that is designed to monitor the queue and read 10 messages (for example) and then start the threads and then wait for one to finish before starting any more. For all intents and purposes I am trying to create a 'thread pool' or 'work queue' that prevents too many processes from starting up at any one time.

OR

Does this need to be thread pooled outside of ActiveMQ ?

I'm new to JMS and am beginning to understand it but still a long way to go.

Any help is appreciated.

Trevor

Upvotes: 0

Views: 592

Answers (1)

Tim Bish
Tim Bish

Reputation: 18421

What you are looking to do sounds like something that could easily be solved using Apache Camel. Take a look at the Camel documentation for the competing consumers EIP which sounds like an ideal fit for your case.

Upvotes: 1

Related Questions