Quartz CronTriggers in Akka Actors using or not using Camel?

I have a Db Quartz CronTriggers. I want to transfer this entire system to the base based on Akka, which I am currently archiving. I looked and thought about how this can be done.

For example, CustomRouteBuilders and other similar things. I tried a great example of Quartz-Camel-Akka Giovani integration and was very impressed with it. Now I have several cron triggers on my system with different and user-created cron expressions.

How can I program the Camel Consumer Actors system with such user-dependent endpointUri? Thought of many options, but could not understand anything.

Please help me in this endeavor. I am also open to other ideas besides Quartz and Camel. I want to stick to the base Akka platform. My system consists of user-defined tasks that fire when cron timers are set by the user.

+7
source share
1 answer

Starting with a list of cron expressions (for example, read from a database), you can iterate over the list and run a quartz consumer for each item. Here is an example:

import akka.actor.Actor import akka.actor.Actor._ import akka.camel.CamelServiceManager._ import akka.camel.Consumer object CronExample { def main(args: Array[String]) { val cronExpressions: List[String] = ... // cron expressions read from database startCamelService cronExpressions foreach { cronExpression => val timerName: String = ... // app-specific timer name for cronExpression actorOf(new Scheduler(timerName, cronExpression)).start } } class Scheduler(timerName: String, cronExpression: String) extends Actor with Consumer { def endpointUri = "quartz://%s?cron=%s" format (timerName, cronExpression) protected def receive = { case msg => ... // react on timer event } } } 
+9
source

All Articles