How to delay consuming messages in Apache Camel from ActiveMQ

醉酒当歌 提交于 2019-12-04 17:54:28
Fritz Duchardt

In another SO thread the winning answers promotes the following solution:

from("activemq:queueA").throttle(10).to("activemq:queueB")

To me this solution only makes sense, if you define a prefetch limit, without which the consumer would not care about any downstream throttling. This route should work:

from("activemq:queueA?&destination.consumer.prefetchSize=10").throttle(10).to("activemq:queueB")

This is the threory behind it, right from http://activemq.apache.org/what-is-the-prefetch-limit-for.html

So ActiveMQ uses a prefetch limit on how many messages can be streamed to a consumer at any point in time. Once the prefetch limit is reached, no more messages are dispatched to the consumer until the consumer starts sending back acknowledgements of messages (to indicate that the message has been processed). The actual prefetch limit value can be specified on a per consumer basis.

You can enable scheduled delivery of ActiveMQ and then set in your Camel Route AMQ_SCHEDULED_DELAY header and then send your exchange to a queue. This will result to introducing a delay of AMQ_SCHEDULED_DELAY millis before the message appears in the queue (i.e. be available for consumption).

Check this: http://activemq.apache.org/delay-and-schedule-message-delivery.html

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