问题
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