Re: Quartz Job Scheduler with play

1,320 views
Skip to first unread message

Raju Bishnoi

unread,
Dec 27, 2012, 11:26:44 PM12/27/12
to play-fr...@googlegroups.com
Hi,

Waiting for response.
Can any guy reply me on below my question.

Thanks
Raju

On Thursday, 27 December 2012 14:12:22 UTC+5:30, Raju Bishnoi wrote:
Hi everyone,

We are running the application in core java with quartz job scheduler(add/update/delete jobs).
Now we are moving it to play framework(with akka distribution), so i want the help regarding the integration of QUARTZ job scheduler in play framework.
I gone through the play and akka docs but didn't get how to implement it.
We want quartz job scheduler with add/update/delete jobs functionality.

Please help us ASAP.

Thanks
Raju

Ronald

unread,
Jan 3, 2013, 6:33:03 AM1/3/13
to play-fr...@googlegroups.com
Hi,
this is a simple example of a job that is fired every midnight.

// Global.scala
v
al scheduler = StdSchedulerFactory.getDefaultScheduler()

override def onStart(app: Application) {

 scheduler
.start()
 val job
= newJob(classOf[MyWorker]).withIdentity("job1", "group1").build();


 val trigger
= newTrigger()
   
.withIdentity("myWorker", "group1")
   
.withSchedule(dailyAtHourAndMinute(0, 0))
   
.forJob(job)
   
.build()


 scheduler
.scheduleJob(job, trigger)
}


override def onStop(app: Application) {
 scheduler
.shutdown()
}


class MyWorker extends Job {
 
def execute(ctxt: JobExecutionContext) {
   
Logger.debug("Do what you are there for!")
 
}
}

Mariot Chauvin

unread,
Jan 6, 2013, 5:28:22 PM1/6/13
to play-fr...@googlegroups.com
I just published a tiny module to work with quartz seamlessly : https://github.com/mchv/play2-quartz

Mariot

2013/1/3 Ronald <r.me...@gmail.com>
--
 
 



--
Mariot Chauvin,
Project Manager at Zenexity C×Ɔ

Mushtaq Ahmed

unread,
Jan 7, 2013, 10:38:05 AM1/7/13
to play-fr...@googlegroups.com
Does it work with Play2.1-RC1?


--
 
 

Mariot Chauvin

unread,
Jan 7, 2013, 10:45:55 AM1/7/13
to play-fr...@googlegroups.com
not yet I will publish a version compatible with Play 2.1-RC2 when it will be available.
 

2013/1/7 Mushtaq Ahmed <mush...@gmail.com>
Message has been deleted

Justin

unread,
Jan 7, 2013, 11:04:19 AM1/7/13
to play-fr...@googlegroups.com
Akka scheduler by itself can also do this.

The following is for the daily job.

def registerDailyJob(job: () => Unit, hour:Int, minute:Int) {
    val minMs
= 60 * 1000
    val hourMs
= minMs * 60
    val dayMs
= hourMs * 24


    val initialDelayMs
= getNextInitialDelayMs(Calendar.getInstance(), hour, minute)


   
Logger.debug("registerDailyJob " + initialDelayMs + ", " + dayMs)
   
Akka.system.scheduler.schedule(initialDelayMs milliseconds, dayMs milliseconds) {
      job
()
   
}
 
}


 
def getNextInitialDelayMs(from:Calendar, hour:Int, minute:Int):Long = {
   
var next:Calendar = from.clone().asInstanceOf[Calendar]
   
next.set(Calendar.HOUR_OF_DAY, hour)
   
next.set(Calendar.MINUTE, minute)
   
if (next.compareTo(from) < 0)
     
next.add(Calendar.DATE, 1)


   
next.getTimeInMillis - from.getTimeInMillis
 
}


2013년 1월 8일 화요일 오전 12시 45분 55초 UTC+9, Mariot Chauvin 님의 말:
Reply all
Reply to author
Forward
0 new messages