Listener which notifies when job initialization is done with QUARTZ 2.2.x - quartz-scheduler

I have implemented quartz 2.2.0 for the scheduling job in my project.
Now i want to check some conditions before job starts.
So is there any listener method that can notify me when job initialized or when it is going to run for the first time.
Thanks in advance.

Related

Stopping the execution of a currently running job after some time

I am using quartz to schedule jobs to be executed daily as a part of a much larger web application. However, after a couple of days, the administrator would like to stop the execution of a particular job (maybe because it is no longer needed). How do I go about doing this? I read the api docs for the Scheduler and it has a method called interrupt(JobKey jobkey) but that method would work only with the same instance of the scheduler that was used to schedule the job.
interrupt(JobKey jobKey)
Request the interruption, within this Scheduler instance, of all
currently executing instances of the identified Job, which must be an
implementor of the InterruptableJob interface.
Is there anyway of getting the instance of an existing scheduler? Or maybe use singletons?
Should definitely use a singleton instance of your scheduler. I recommend the use of an IoC container to manage this in a clean and efficient way.

pause & shutdown quartz immediately

When I pass over a request from the UI, assign the specific job Pause or Shutdown.
How could I make the job stop immediately?
For the method scheduler.pauseJob(JobKey.jobKey(jobName)); in quartz will run finish this job, then it will stop. It takes me a so long time to deal with the problem.
Thanks in advance.

Running actor manually?

I'm working on my first Play Framework 2 application. I want to call a web service every once in a while and store data in the database so I've started writing an actor that is scheduled to every hour.
Problem is, I'm wasting a lot of time simply waiting for the job to be triggered (even if I've scheduled to be ran every minute while I'm testing. I'd love to be able to start the import manually, simply to make sure it works.
I've tried using the scala console, but it doesn't automatically reload my code every time I save so I have to restart the console manually. I've considered wrapping the import process in a class and use unit testing and mocking but I'm looking for a quicker way, especially because I'm new to Play and Scala.
Any idea or suggestion?
Thanks!
How about writing a custom sbt task?
A simple way to write an sbt task that loads your application class path, so you can implement the behavior with a method call in your application code, can be found at sbt-tasks.
I'm assuming you are using the Akka scheduler inside the Actor to trigger a message to itself which then invokes web service. You can just send same message (ActorRef ! Message) to the actor while you are doing your testing.

Can Quartz Scheduler Run jobs serially?

I'm looking into using Quartz Scheduler, and I was wondering if it was possible to schedule jobs not by time, but when another job finishes. So, when Job A is done, it starts Job B. When that's done, it starts Job C, etc.
Job A -> Job B -> Job C -> Job A... continuously.
Is this the right tool for the job? Or should I be looking into something else?
Check out JobChainingJobListener, built-in to Quartz (bold mine):
Keeps a collection of mappings of which Job to trigger after the completion of a given job. If this listener is notified of a job completing that has a mapping, then it will then attempt to trigger the follow-up job. This achieves "job chaining", or a "poor man's workflow".
That's right, you are looking for a process or workflow engine. Have a look at activiti or jbpm.
You may want to check the QuartzDesk project I have been involved in. QuartzDesk is a management and monitoring platform for Quartz-based apps and in version 2.0 we have added a new job chaining engine to the platform.
The engine allows you to orchestrate the execution of your jobs and there is no need to modify your application code in any way. Job chains can be dynamically updated through the QuartzDesk GUI without any disruption to your application.

Quartz scheduler: Vetoing job execution causes trigger to never fire again

I am working with a quartz implementation in a Java web app. We have implemented the TriggerListener class so when a trigger fires, it calls the vetoJobExecution(Trigger trigger, JobExecutionContext jobExecutionContext) method. We check a reference table to see if the job should run or not. All of this works fine.
The part that is broken is if the job should NOT run, so the vetoJobExecution method returns false. After that happens, the trigger will never fire again. This is the part I do not understand. It seems like the trigger should continue firing, and the vetoJobExecution method should keep being called to see if the job should run. This simply doesn't happen - once the job is vetoed, the trigger does not fire again and the vetoJobExecution method is never called.
We are using Quartz 1.5.2 (yeah it's old, I know).
What is the correct strategy for having a quartz job not run using the TriggerListener interface, yet still having the trigger fire next time?
Fixed by upgrading to version 1.7.3.