Quartz.Net and passing data between chaining jobs

℡╲_俬逩灬. 提交于 2019-12-21 20:23:11

问题


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(trigger);

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

What's wrong?


回答1:


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");


来源:https://stackoverflow.com/questions/7259418/quartz-net-and-passing-data-between-chaining-jobs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!