问题
Using Camel Throttler component you can define an upper limit on the rate of consumed messages per time period, e.g.:
from("activemq:queueA").throttle(10).to("direct-vm:bla")
What I see as non ideal is that Camel Throttler keeps the exchanges in-memory while they are blocked by the Throttler. So, if you have 100 queue consumers and for any reason the "direct-vm:bla" is slow (e.g. invoking external slow service), you may have in-memory up to 100 exchanges!
I was wondering if there is an ActiveMQ feature to impose the throttling requirement on the ActiveMQ level. Maybe even on a per queue level. Something similar to consumer-max-rate of HornetQ.
回答1:
Configure the consumer to use a transaction (doesn't have to be an XA transaction. If you only have 1 other endpoint use a local JMS transaction. see: LLR transaction approach). If the Camel route fails, the messages roll back to the broker.
来源:https://stackoverflow.com/questions/37462059/throttle-consumption-rate-of-all-jms-consumers-listening-on-an-activemq-queue