Announcement Announcement Module
Collapse
No announcement yet.
schedule spring batch job on demand/dynamically Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • schedule spring batch job on demand/dynamically

    Hi,

    I am having a problem. I want to create/schedule a quartz job dynamically/on-demand. I am able to do create and run quartz job dynamically/on-demand using spring-version lower then 3.1 and quartz-version lower then 2.1.
    Since most of the code are deprecated in the higher version in spring ( 3.1+ ) I am having problem to create JobDetail, Trigger and to start scheduler.

    Here is a sample code I tried but it did not work for me. Can anyone help me.
    Code:
                            JobDetailFactoryBean j = new JobDetailFactoryBean();
    			j.setJobClass(FirstJobDetails.class);
    
    			CronTriggerFactoryBean c1 = new CronTriggerFactoryBean();
    			c1.setJobDetail(j.getObject());
    			c1.setCronExpression("0/30 * * * * ?");
    
    			SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
    
    			Trigger[] triggers = new Trigger[]{c1.getObject()};
    			schedulerFactoryBean.setTriggers(triggers);
    			schedulerFactoryBean.start();
Working...
X