Throttle consumption rate of all JMS consumers listening on an ActiveMQ queue

折月煮酒 提交于 2019-12-12 03:27:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!