Announcement Announcement Module
No announcement yet.
Self-scheduling Quartz jobs Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Self-scheduling Quartz jobs

    I've looked through the Spring and Quartz documentation, but can't see the solution.

    I'm running in a Websphere 5.0.2 environment and I have a need for a job (call it UberJob) that runs every 8 hours looking for missing parts from orders. For any parts that it finds, I want to run concurrent jobs (ConcurrentJob) for each part that searches the vendors.

    From what I've read, UberJob can get a (partially set-up) prototype ConcurrentJob from the applicationContext by exposing an applicationContext property. UberJob can then tell ConcurrentJob what part number to look for, but what would be the best way to get a handle to the scheduler so I can trigger it?
    Simply get the scheduler from the factory through the appContext?
    Is there a property I can create where it will be provided (i.e. setScheduler)?
    Or should I wire the scheduler factory to UberJob in the context XML? I noticed in the reference doc your example doesn't have an id or name set on the factory (to discourage this misuse probably).

    Thanks in advance for any help.

  • #2
    Simply use context.getScheduler() in your Job:

    public class MyJob implements Job {  
       * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
      public void execute(JobExecutionContext context) throws JobExecutionException {
        Scheduler scheduler =  context.getScheduler();