How to delay start of Quartz scheduler?
I wired up a Quartz schedule using Spring. Sweet. However, using a simple approach, such as the SimpleTrigger, the job starts up right away, based on the start delay. Problem is some runtime parameters will be supplied that must be inserted into the actual task (query parameters).
How can the job be fired manually after the Spring context is set up, etc.? I looked at the Quartz doc and don't see it yet. Hoping Spring devs have already done something like this.
--- Josef
Solved. The SchedulerFactoryBean has an 'autoStartup' flag field. But, now I have to get an instance of the factory bean so that I can execute start().
Do you mean you need an instance of the Scheduler so you can execute start()? I guess you could do this declaratively with an init-method=quot;startquot;, and a depends-on to force the bean to wait for the other things it needs to initialise.
Or you could use an ApplicationListener wired with the Scheduler and listen for ContextRefreshedEvent?
Continuing with my quot;hackquot;, I just added another field to the driver class, and now I have access to the Quartz schedular. This app is just for diagnostics so it can be inelegant for now.
autowireBean(app.ctx, app); // let Spring autowire-byname me. app.queryLoader.parse(); // get JDBC queries app.schedulerFactory.start(); // let the queries rip using Quartz
Thanks. |