Quartz.Net 工作进展
IJob 是否有一种简单的方法可以从作业中发布数据。 我有一个正在运行导入过程的作业,但希望通过查找该作业并请求它来检索进度。
我认为我也许可以使用 JobDetails,但似乎没有反映作业中所做的更改?
Is there an easy way for a IJob to publish data from within the Job. I have a Job running an import process, but would like to retrieve the progress by looking up the Job and requesting it.
I thought that i may be able to use the JobDetails, but does not seem to reflect the changes made within the Job?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有一种内置方法可以轻松地为您提供您正在寻找的东西。 但通过发布订阅向其他设施发布进度信息也不是那么困难。 您还可以定期将进度信息写入持久存储 - 当您知道处理的最后一个成功位时,这也将为您带来轻松重试的好处。
如果外部线程/进程轮询您要导入的目标,并且您将在某处获得有关要导入的总项目的信息,则它也可以确定状态。
Quartz.NET 作业是作为一个......井单元进行处理的单元,因此不存在还有多少工作要做的概念。 或者您在另一项依赖于导入流程的工作中需要此信息吗?
There isn't a built-in way that would give you easily the thing you are looking for. But it isn't that hard to publish progress info to some other facility via publish subscribe either. You could also periodically write progress info to persistent storage - that would also give you the benefit of easy retry when you know the last successful bit that was processed.
An outside thread/process could also determine the status if it polled the target where you are importing and you would have somewhere the info about total items that are going to be imported.
Quartz.NET jobs are units that are processed as an.. well unit and so there isn't the notion of how much there is yet to be done. Or do you need this info in another job that depends on import process?
这是很有可能。
我会选择这样的东西。
在作业中:
在想要检索进度的代码中:
当然,您可以过滤 GetCurrentlyExecutingJobs 的结果。
此外,您可以将作业设置为“Durable”和“PersistJobDataAfterExecution”,因此在完成后,您可以通过“scheduler.GetJobDetail(.. ) 并随后访问其
JobDataMap
。It is quite possible.
I would go with something like this.
In job:
In code that wants to retrieve progress:
You can filter result of GetCurrentlyExecutingJobs, of course.
Also, you can set job to be
Durable
andPersistJobDataAfterExecution
, so after it is done, you can retrieve its progress and anything else viascheduler.GetJobDetail(..)
and accessing itsJobDataMap
afterwards.