Created
March 3, 2013 23:39
-
-
Save aphexmunky/5078917 to your computer and use it in GitHub Desktop.
Taken from stackoverflow example - not my code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment