Announcement Announcement Module
Collapse
No announcement yet.
Exposing the Quartz Scheduler Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exposing the Quartz Scheduler

    Hi all,

    I'm trying using a SchedulerFactoryBean in my application to help schedule quartz tasks. This seems great for adding tasks with pre-defined schedules (as the documentation shows), but how does one access the internal scheduler so as to be able to add tasks to it in the future?

    My app creates jobs on the fly that are scheduled to execute in the future (and are persisted via JDBC in the interim). I can't seem to figure out how the scheduler is exposed (as a named bean would be the obvious way) for programmatic access, and that has me dead in the water for the time being.

    Thanks much for any help,
    Dolan Halbrook

  • #2
    Re: Exposing the Quartz Scheduler

    Originally posted by dhalbrook
    Hi all,

    I'm trying using a SchedulerFactoryBean in my application to help schedule quartz tasks. This seems great for adding tasks with pre-defined schedules (as the documentation shows), but how does one access the internal scheduler so as to be able to add tasks to it in the future?

    My app creates jobs on the fly that are scheduled to execute in the future (and are persisted via JDBC in the interim). I can't seem to figure out how the scheduler is exposed (as a named bean would be the obvious way) for programmatic access, and that has me dead in the water for the time being.

    Thanks much for any help,
    Dolan Halbrook
    What do you mean "internal scheduler"? When you define a scheduler through the scheduler factory bean, you can just use it with dependency injection by declaring another bean which receives a Scheduler property and a "property" tag which sets it with a reference to the scheduler itself. You then use the scheduler api in order to set new jobs.

    Comment


    • #3
      Thanks for the suggestion. It sounds like what I'm describing is possible.

      Could you clarify with an example of how one would do what you described in the Spring config? I'm still a little hazy on the terminology, so that would be enormously useful.

      By "internal scheduler", i meant the scheduler that is a member of (and bootstrapped by) the SchedulerFactoryBean by default. It sounds like what you're suggesting is to override the default scheduler with my own named definition and access that instead. Would this be done by setting the "schedulerName"?

      I wasn't sure how to access what I described as the "internal scheduler" since there are no bean accessors for that scheduler in the SchedulerFactoryBean that I can see.

      Comment


      • #4
        Re: Exposing the Quartz Scheduler

        +1

        I'm trying to do the exact same thing. I have a pre-defined Job but need to create unique Triggers and JobExecutionContexts so users in my system can run the job at a frequency of their own choosing (once a day, once a week, etc) and personalized for them.

        immanuel, your response, while appreciated, doesn't help much. I'm sure it's possible - I just need a concrete example of how it's done. The SchedulerFactoryBean does not seem to expose its internal Scheduler.

        Originally posted by dhalbrook
        My app creates jobs on the fly that are scheduled to execute in the future (and are persisted via JDBC in the interim). I can't seem to figure out how the scheduler is exposed (as a named bean would be the obvious way) for programmatic access, and that has me dead in the water for the time being.

        Comment


        • #5
          Duh, it seems obvious in retrospect. The SchedulerFactoryBean is the QuartzScheduler object. It's a FactoryBean so the getObject method returns the QuartzScheduler object. You just define a QuartzScheduler property in your Java class and in the Spring context, set that property to the SchedulerFactoryBean.

          Originally posted by dhalbrook
          I wasn't sure how to access what I described as the "internal scheduler" since there are no bean accessors for that scheduler in the SchedulerFactoryBean that I can see.

          Comment


          • #6
            Good catch. Somehow I missed that going through the code of the SchedulerFactoryBean. Much clearer now. Guess I was looking for something more akin to "getScheduler".

            Comment

            Working...
            X