Quartz Scheduler: How to pass custom objects as JobParameter?

后端 未结 5 1764
时光说笑
时光说笑 2020-12-06 16:28

I am planning to write a ASP.NET page to trigger the job on demand. Currently, I am using SimpleTrigger class to trigger the job but none of the __Trigger class supports obj

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 17:19

    I passed the object following way

    JobDetail job1 = JobBuilder.newJob(JobAutomation.class)
                    .usingJobData("path", path)
                    .withIdentity("job2", "group2").build();
    
            CronTrigger trigger1 = TriggerBuilder.newTrigger()
                    .withIdentity("cronTrigger2", "group2")
                    .withSchedule(CronScheduleBuilder.cronSchedule("40 27 11 * * ?"))
                    .build();
    

    get jobdatamap by following lines of code

    JobDataMap dataMap = context.getJobDetail().getJobDataMap();
    String path =dataMap.getString("path");
    

提交回复
热议问题