更新 Quartz.NET 作业 DLL,无需重新启动服务
我刚刚开始使用 Quartz.net,并将其作为服务运行。我创建了一个作业,并将生成的 .dll 移至 Quartz 文件夹,并向 jobs.xml 文件添加了一个新条目,以每 3 秒启动一次。
我更新了作业 .dll,但 Quartz 正在使用它(或已锁定)。
是否可以在不重新启动 Quartz 服务的情况下更新 .dll?如果不是,如果我停止/启动 Quartz 服务,长时间运行的作业会发生什么情况?
I just started with Quartz.net and I have it running as a service. I created a Job and moved the resulting .dll to the Quartz folder and added a new entry to the jobs.xml file to kick it off every 3 seconds.
I updated the job .dll but it is in use by Quartz (or is locked).
Is it possible to update the .dll without restarting the Quartz service? If not what would happen to a long running job if I did stop/start the Quartz service?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果不重新启动服务,则无法更新作业 dll。服务器启动后,它会加载作业 dll,并且加载的类型保留在内存中。这就是 .NET 运行时的工作原理。要实现动态重新加载之类的功能,您需要使用以编程方式创建的应用程序域等。
如果停止调度程序,您可以传递一个 bool 参数是否首先等待作业完成。这样你就可以安全地完成作业,并且在调度程序关闭时不会产生新的作业。
You cannot update the job dll without restarting the service. Once the server has started it loads the the job dll and the loaded types stay in memory. This is how .NET runtime works. To achieve something like dynamic reloading you would need to use programmatically created app domains etc.
If you stop the scheduler you can pass a bool parameter whether to wait for jobs to complete first. Then you would be safe with jobs completing and no new ones would spawn meanwhile the scheduler is shutting down.