0

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 6 AM to 5 PM,
Queue 2 messages should be sent only between 10 AM to 10 PM like that.

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

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

iknow
  • 8,358
  • 12
  • 41
  • 68
siddu
  • 99
  • 1
  • 1
  • 6

2 Answers2

2

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.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • i got some idea on the link u mentioned above but i actually want to know like: My new Requirement: There will be only 1 queue in activeMq, and i have different social hours based on day of week. For eg on Monday i have to pick up messages from 10am to 8pm and Tuesday 10am to 6pm so on.. On different day i have different timings. So can u suggest me how i can solve this problem. – siddu Jan 18 '13 at 13:23
  • I thought of doing like this CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy(); String routeStartTime = "0 0 12 * * ?"; String routeStopTime = "0 0 24 * * ?"; policy.setRouteStartTime(routeStartTime); policy.setRouteStopTime(routeStopTime); from("activemq:queue:notificationServiceSMSQueue").routeId("o2sms").routePolicy(policy).throttle(throttledSmsCount) .timePeriodMillis(throttledSmsDuration).to("smsMessageProcessor"); routeStartTime and routeStopTime i will get it based on day of week timings. Is it rite approach to proceed, if not suggest some better approach. – siddu Jan 18 '13 at 13:27
0
  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.
Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84