Throttling based on time interval

2019-09-11 11:30发布

I have 4 queues in ActiveMq and messages from each queue should be sent out to external service, for picking up the messages from queue i am using Apache Camel and i am throttling the messages. But my problem here is for different queues i have different social hours, For E.g. Queue 1 messages should be sent only between 6AM to 5PM, Queue 2 messages should be sent only between 10AM to 10PM like that.

So i want to know can we handle this using Apache camel throttling. Or please suggest me some solution.

Let me know if anyone not cleared with my problem. ThankU in advance.

2条回答
时光不老,我们不散
2楼-- · 2019-09-11 11:58
  1. Set up one route per queue/interval.
  2. Use Quartz timers triggered on those hours that should start/stop the routes.
  3. You can let the Quartz routes use the control bus pattern to start/stop the queue routes.
查看更多
Root(大扎)
3楼-- · 2019-09-11 12:02

Camel allows you to associate route(s) with route policies. And we have an out of the box policy that is based on camel-quartz and is scheduled based. This allows you to setup policies for opening hours of your routes.

The doc starts here: http://camel.apache.org/routepolicy. And there is links from that page to the the scheduler based policies.

Mind there is a ticket - http://issues.apache.org/jira/browse/CAMEL-5929 - about if you restart the app server, then the route is not started if you start within the opening hours. eg your have 12pm-6pm. And you restart the app at 3pm (eg in between). Then the route i started on the next day. The ticket is there to allow you to configure to force start if being started within the opening window.

查看更多
登录 后发表回答