Quartz.net 和/或 MSMQ?

发布于 2024-10-22 06:53:28 字数 298 浏览 6 评论 0原文

我正在编写一个需要在特定时刻运行任务的应用程序,因此我计划使用 Quartz.NET 来实现此目的。不过,需要运行的任务有多个步骤,其中一些步骤可能有点密集,因此我正在考虑使用 MSMQ 之类的东西对任务的每个部分进行排队,并使用较小的集中子任务来分散负载,而不是一点任务。

唯一的问题是,它会绕过我想用来确保任务完成的 Quartz.NET 失败任务功能。

任何人都可以建议一种单独使用 Quartz.NET 来完成所有操作的方法吗?或者如何使用MSMQ,并且仍然能够使用Quartz.NET“任务失败”功能? (或者我可能不知道的任何其他方式?)

I'm writing an app that needs to run a task at a specific moment in time so I am planning to use Quartz.NET for this. The task that needs to run though, has multiple steps, some of which could be a little intensive, so I was thinking of using something like MSMQ to queue each part of the task, and have smaller focused sub tasks that spread the load, than one bit task.

The only problem with this, is that it would then bypass the Quartz.NET failed task feature that I would like to use to ensure a task completes.

Can anyone suggest a way to use either Quartz.NET alone to do everything? or how to use MSMQ aswell, and still be able to use the Quartz.NET "task failure" feature? (or any other way I may not know of?)

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

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

发布评论

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

评论(3

狼性发作 2024-10-29 06:53:28

这听起来很像 NServiceBus 中构建于 MSMQ 之上的传奇的概念。您将工作分派给节点,它们会以工作(或失败)进行响应。然后,传奇会协调接下来应该发生的任务。

主要原因

之一使用 NServiceBus 的原因是它为您抽象了很多基础设施,并且让您专注于业务行为以及与该行为相对应的事件。

This sounds a lot like the concept of a saga within NServiceBus which is built on top of MSMQ. You dispatch work to nodes and they respond back with their work (or failures). The saga then coordinates what tasks should happen next.

http://docs.particular.net/nservicebus/sagas/

One of the primary reasons to utilize NServiceBus for this is that it abstracts away a lot of the infrastructure for you and it has you focus in on business behavior and the events corresponding to that behavior.

羞稚 2024-10-29 06:53:28

您可以从 Quartz.Net 任务中安排其他任务。这将使您能够对所有子选项卡使用任务失败功能,但您无法将其应用于主任务。这本质上提供了您想要实现的相同功能,而无需使用 MSMQ。

You can schedule other tasks from within a Quartz.Net task. This would give you the ability to use the task failure feature for all of the sub tabs, but you wouldn't be able to apply this to the main task. This provides in essence the same feature you wanted to implement, without having to use MSMQ.

请帮我爱他 2024-10-29 06:53:28

该问题仅指定分散工作负载是可取的,而不是将异步调用中的控制权移交给另一个任务/进程/消息处理程序。

在这种情况下,Quartz 作业可以将“任务”消息推送到 MSMQ 上,以便其他一些服务接收。然后,它可以在退出 Execute 方法之前等待另一个队列上的“响应”消息。它可以通过轮询该队列来做到这一点。一旦收到成功或失败消息,它就可以干净地退出 Execute 方法,或者通过抛出 JobExecutionException 来退出。

这个解决方案不太优雅。请求/响应机制和传输可以被抽象出来,例如通过 WCF 或 NServiceBus,但事实上,您隐式地追求基本上是双工通信,这意味着它不太适合 MSMQ。不过这是可能的(请参阅http://www.codeproject.com/Articles/41907/ WCF-Duplex-MSMQhttp://docs.pspecial.net/samples/fullduplex/ )。您可能会更好地使用一系列某种类型的 Web 服务,异步调用它们并等待所有完成。

The question only specifies that spreading the load of the work is desirable, rather than handing off control in an asynchronous call to another task/process/message handler.

That being the case, the Quartz job could push 'task' messages onto MSMQ for some other services to pick up. It could then wait for 'response' messages on another queue before exiting the Execute method. It could do this by polling that queue. Once it has received either a success or failure message it can then exit the Execute method either cleanly or by throwing a JobExecutionException.

This solution isn't too elegant. The request/response mechanism and transport can be abstracted out, e.g. by WCF or NServiceBus, but the fact that you're implicitly after what is basically a duplex communication means that it isn't well suited to MSMQ. It's possible though (see http://www.codeproject.com/Articles/41907/WCF-Duplex-MSMQ or http://docs.particular.net/samples/fullduplex/). You may just be better using a series of web services of some kind, asynchronously invoke them and wait on all the completions.

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