Skip to content

Instantly share code, notes, and snippets.

@aphexmunky
Created March 3, 2013 23:39
Show Gist options
  • Save aphexmunky/5078917 to your computer and use it in GitHub Desktop.
Save aphexmunky/5078917 to your computer and use it in GitHub Desktop.
Taken from stackoverflow example - not my code
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