Quartz.Net 和在链接作业之间传递数据
我必须实施一个简单的工作流程。
某些作业 A 必须在指定时间运行(cron 触发器)。该作业搜索未处理的数据(比如说一些 IThingToDo[])并对其进行处理。作业 B 必须在作业 A 完成后立即执行,并且已处理的数据列表 (ITingToDo[]) 应传递给它。
作业 A 存储这样的数据:
context.Put("Things", things);
然后我使用 IJobListener 来了解作业 A 何时完成,获取“Things”数组并为作业 B 创建触发器:
Trigger trigger = new SimpleTrigger("JobBTrigger", "NS", DateTime.Now);
trigger.JobName = "JobB";
trigger.JobGroup = "NS";
trigger.JobDataMap.Put("Things", things);
context.Scheduler.ScheduleJob(trigger);
这工作正常。除了我无法从作业 B 中获取“事物”之外,context.Get(“事物”) == null。
怎么了?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了答案。我只需要使用 MergedJobDataMap (它是来自 JobDetail 和触发器的组合 JobDataMap):
I've found an answer. I just had to use MergedJobDataMap (which is a combined JobDataMap from a JobDetail AND a Trigger):