mstrom
mstrom

Reputation: 1743

How to control number of messages ActiveMQ is processing asynchronously?

I'm new to ActiveMQ. I'm using it (and Apache Camel) for batch processing that ends up communicating with web services.

My question is how does ActiveMQ control how asynchronous it really is? In other words, if it can process 20 messages at the same time but the bottleneck is the web services on the other end, how can I control that? Can I slow ActiveMQ down?

Thanks!

Upvotes: 1

Views: 1570

Answers (3)

Clocker
Clocker

Reputation: 1336

You could also set a pre-fetch limit, preventing AMQ from dispatching messages on a specific transport to its consumers based on the amount of message_delivered responses it gets back from the client. Here is a reference

Upvotes: 0

Claus Ibsen
Claus Ibsen

Reputation: 55585

The Camel throttler would be a good solution. It does however keep the messages in memory in the Camel application at the time. However it allows to react precisely.

Another alternative is the throttling in-flight route policy you can configure on the Camel ActiveMQ JMS consumer. That policy can be configured with a upper/lower water mark settings. Then the policy will automatic suspend/resume the AMQ consumer accordingly. You can extend this logic and use your custom metrics instead.

You can read about this policy here: http://camel.apache.org/routepolicy

This approach would then not keep any messages in memory, as it will control on the AMQ consumer side to suspend/resume it to "throttle" the flow.

Upvotes: 2

ali haider
ali haider

Reputation: 20192

if you're using apache camel 2.4+, you can use the throttler with camel to control message flow to endpoints - you can change the limit dynamically as of camel 2.8 - hope it helps.

Upvotes: 2

Related Questions