开发者

Quartz.Net and passing data between chaining jobs

开发者 https://www.devze.com 2023-04-01 06:21 出处:网络
I\'ve got to implement a simple workflow. Some job A have to run at specified time (cron trigger). This job searches for unprocessed data (let\'s say some IThingToDo[]) and process it. Job B has to b

I've got to implement a simple workflow.

Some job A have to run at specified time (cron trigger). This job searches for unprocessed data (let's say some IThingToDo[]) and process it. Job B has to be performed just after job A finished and the list of processed data (IThingToDo[]) should be passed to it.

Job A stores data like this:

context.Put("Things", things);

Then I use IJobListener to know when job A finished, get the "Things" array and create a trigger for job B:

Trigger trigger = new SimpleTrigger("JobBTrigger", "NS", DateTime.Now);
trigger.JobName = "JobB";
trigger.JobGroup = "NS";
trigger.JobDataMap.Put("Things", things);
context.Scheduler.ScheduleJob(开发者_Go百科trigger);

This works fine. Except that I can't get "Things" from job B, context.Get("Things") == null.

What's wrong?


I've found an answer. I just had to use MergedJobDataMap (which is a combined JobDataMap from a JobDetail AND a Trigger):

var things = context.MergedJobDataMap.Get("Things");
0

精彩评论

暂无评论...
验证码 换一张
取 消