Quartz.NET 与 Windows 计划任务。他们有多不同?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5115105/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:16:40  来源:igfitidea点击:

Quartz.NET vs Windows Scheduled Tasks. How different are they?

windowsscheduled-tasksschedulingquartz.net

提问by Serge Wautier

I'm looking for some comparison between Quartz.NETand Windows Scheduled Tasks?

我正在寻找Quartz.NET和 Windows 计划任务之间的一些比较?

How different are they? What are the pros and cons of each one? How do I choose which one to use?

他们有多不同?每一种的优缺点是什么?我该如何选择使用哪一种?

TIA,

TIA,

采纳答案by Marko Lahma

With Quartz.NET I could contrast some of the earlier points:

使用 Quartz.NET,我可以对比之前的一些观点:

  1. Code to write - You can express your intent in .NET language, write unit tests and debug the logic
  2. Integration with event log, you have Common.Logging that allows to write even to db..
  3. Robust and reliable too
  4. Even richer API
  1. 要编写的代码 - 您可以用 .NET 语言表达您的意图,编写单元测试并调试逻辑
  2. 与事件日志集成,你有 Common.Logging 甚至允许写入 db..
  3. 坚固可靠
  4. 更丰富的API

It's mostly a question about what you need. Windows Scheduled tasks might give you all you need. But if you need clustering (distributed workers), fine-grained control over triggering or misfire handling rules, you might like to check what Quartz.NET has to offer on these areas.

这主要是关于您需要什么的问题。Windows 计划任务可能会为您提供所需的一切。但是如果你需要集群(分布式工作者),对触发或失火处理规则的细粒度控制,你可能想检查 Quartz.NET 在这些方面提供了什么。

Take the simplest that fills your requirements, but abstract enough to allow change.

取最简单的满足您的要求,但足够抽象以允许更改。

回答by stephbu

My gut reaction would be to try and get the integral WinScheduler to work with your needs first before installing yet another scheduler - reasoning:

我的直觉反应是在安装另一个调度程序之前先尝试让集成的 WinScheduler 满足您的需求 - 推理:

  1. no installation required - installed and enabled by default
  2. no code to write - jobs expressed as metadata
  3. integration with event log etc.
  4. robust and reliable - good enough for MSFT, Google etc.
  5. reasonably rich API - create jobs, check status etc.
  6. integrated with remote management tools
  7. security integration - run jobs in different credentials
  8. monitoring tooling
  1. 无需安装 - 默认安装并启用
  2. 无需编写代码 - 作业表示为元数据
  3. 与事件日志等集成。
  4. 健壮和可靠 - 对于 MSFT、Google 等来说已经足够了。
  5. 相当丰富的 API - 创建作业、检查状态等。
  6. 与远程管理工具集成
  7. 安全集成 - 在不同的凭据中运行作业
  8. 监控工具

Then reach for Quartz if it doesn't meet your needs. Quartz certainly has many of these features too, but resist adding yet another service to own and manage if you can.

如果 Quartz 不能满足您的需求,请使用它。Quartz 当然也有很多这样的特性,但是如果可以的话,不要添加另一个服务来拥有和管理。

回答by hurcane

One important distinction, for me, that is not included in the other answers is what gets executed by the scheduler.

对我来说,其他答案中没有包含的一个重要区别是调度程序执行的内容。

Windows Task Scheduler can only run executable programs and scripts. The code written for use within Quartz can directly interact with your project's .NET components.

Windows 任务计划程序只能运行可执行程序和脚本。为在 Quartz 中使用而编写的代码可以直接与项目的 .NET 组件交互。

With Task Scheduler, you'll have to write a shell executable or script. Inside of that shell, you can interact with your project's components. While writing this shell code is not a difficult process, you do have to consider deploying the extra files.

使用任务计划程序,您必须编写一个 shell 可执行文件或脚本。在该外壳内,您可以与项目的组件进行交互。虽然编写这个 shell 代码不是一个困难的过程,但您必须考虑部署额外的文件。

If you anticipate adding more scheduled tasks over the lifetime of the project, you may end up needing to create additional executable shells or script files, which requires updates to the deployment process. With Quartz, you don't need these files, which reduces the total effort needed to create and deploy additional tasks.

如果您预计在项目的整个生命周期内添加更多计划任务,您最终可能需要创建额外的可执行 shell 或脚本文件,这需要对部署过程进行更新。使用 Quartz,您不需要这些文件,这减少了创建和部署额外任务所需的总工作量。

回答by InteXX

Unfortunately, Quartz.NET job assemblies can't be updated without restarting the process/host/service. That's a pretty big one for some folks (including myself).

不幸的是,如果不重新启动进程/主机/服务,就无法更新 Quartz.NET 作业程序集。对于某些人(包括我自己)来说,这是一个相当大的问题。

It's entirely possible to build a framework for jobs running under Task Scheduler. MEF-based assemblies can be called by a single console app, with everything managed via a configuration UI. Here's a popular managed wrapper:

完全有可能为在 Task Scheduler 下运行的作业构建一个框架。基于 MEF 的程序集可以由单个控制台应用程序调用,所有内容都通过配置 UI 进行管理。这是一个流行的托管包装器:

I did enjoy my brief time of working with Quart.NET, but the restart requirement was too big a problem to overcome. Marko has done a greatjob with it over the years, and he's always been helpful and responsive. Perhaps someday the project will get multiple AppDomainsupport, which would address this. (That said, it promises to be a lot of work. Kudos to he and his contributors if they decide to take it on.)

我确实很享受使用 Quart.NET 的短暂时间,但是重启需求是一个无法克服的大问题。多年来,Marko 在这方面做得很好,而且他总是乐于助人且反应迅速。也许有一天该项目将获得多个AppDomain支持,这将解决这个问题。(也就是说,这肯定需要大量的工作。如果他和他的贡献者决定接受它,就向他们致敬。)

To paraphrase Marko, if you need:

套用 Marko,如果您需要:

  1. Clustering (distributed workers)
  2. Fine-grained control over triggering or misfire handling rules
  1. 集群(分布式工作者)
  2. 对触发或失火处理规则的细粒度控制

...then Quartz.NET will be your requirement.

...那么 Quartz.NET 将是您的要求。