Quartz.net - 当调度程序在 Windows 服务中运行时触发器不会触发

发布于 2024-09-24 23:09:22 字数 433 浏览 1 评论 0原文

我有一个类库(c#,.net 4.0),它实现了 Quartz.net Scheduler 的包装类以及我想要执行的一堆触发器和作业。这个包装类有一个简单的 Start() 和 Stop() 方法来启动或关闭调度程序。

当我从控制台应用程序实例化我的包装器时,它会注册我的作业+触发器,并且一切正常。所有作业都按预期并按预期执行。当我在 Windows 服务(我将其构建为调度程序的容器)中执行相同的操作时,某些触发器永远不会被触发,而其他触发器则按预期工作。

我所有的触发器都非常简单,比如每 x 分钟执行一次并永远重复。我连接了一个全局 ITriggerListener 并记录了所有内容。丢失的扳机不会触发,也不会失火。就好像他们不存在一样。

不幸的是,我没有设法为 Quartz 使用的 Common.Logging 基础设施设置日志记录,因此我没有任何有关内部发生情况的信息。非常感谢任何帮助。

I've got a class library (c#, .net 4.0) implementing a wrapper class for a Quartz.net Scheduler and a bunch of Triggers and Jobs which I'd like to have executed. This wrapper class has a simple Start() and Stop() mathod to start or shutdown the Scheduler.

When I instanciate my wrapper from a console application, it registers my Jobs + Triggers and everything works fine. All jobs are executing as expected and when expected. When I do the same thing from within a Windows Service (which I have build as a container for the Scheduler) some Triggers never get fired while others do work as expected.

All my Triggers are very simple, like execute every x minutes and repeat forever. I hooked up a global ITriggerListener and logged away everything. The missing Triggers don't fire and they don't misfire. It is as if they are not present.

Unfortunately I didn't manage to set up logging for the Common.Logging infrastructure used by Quartz, so I don't have any information on whats going on inside. Any help is greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你げ笑在眉眼 2024-10-01 23:09:22

您已经提到您在 Windows 服务中运行 Quartz 功能。
我假设您使用继承 ScheduleService 的内容,因此重写 OnStop() 和 OnStart(args() as String) 方法,并且我假设您已在服务 OnStart 方法内注册了 Schedule、作业和触发器。

如果是这种情况,请确保您阻止垃圾收集器“清理”您的对象。

Gc.KeepAlive(object)

例如,假设我们在 Windows 服务的 OnStart 中有一个 System.Timers.Timer。我们必须告诉垃圾收集器不要理会计时器,之前已经在类级别定义了计时器(作为对象变量,而不是本地函数变量)

Private timer As System.Timers.Timer

..并且在 OnStart() 内部

timer As System.Timers.Timertimer = New System.Timers.Timer()
AddHandler timer.Elapsed, AddressOf Tick 'here you define that Tick method will handle it
timer.Enabled = true
timer.Interval = 200000
GC.KeepAlive(timer) 'tell the GC to leave alone the timer

所以它可能是类似的东西与你的石英实施?

You've mentioned you run Quartz functionality inside a Windows Service.
I assume you use something inheriting ScheduleService, hence overriding OnStop() and OnStart(args() as String) methods and I assume you have your Schedule and jobs and triggers registered inside the service OnStart method.

If that's the case, make sure you are preventing the Garbage Collector from "cleaning" your objects.

Gc.KeepAlive(object)

For example, lets imagine we have a System.Timers.Timer inside the OnStart for the windows service. We would have to tell the garbage collector to leave alone the timer, having previously defined de timer at the class level (as an object variable, not as a local function variable)

Private timer As System.Timers.Timer

..and inside the OnStart()

timer As System.Timers.Timertimer = New System.Timers.Timer()
AddHandler timer.Elapsed, AddressOf Tick 'here you define that Tick method will handle it
timer.Enabled = true
timer.Interval = 200000
GC.KeepAlive(timer) 'tell the GC to leave alone the timer

So it could be something similar with your Quartz implementation?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文