【问题标题】:Scheduling generic IJob<> with Quartz .NET and AdoJobStore使用 Quartz .NET 和 AdoJobStore 调度通用 IJob<>
【发布时间】:2012-06-22 11:37:25
【问题描述】:

我正在使用 Quartz .NET 开发简单的调度程序。我想 Quartz 将所有作业和触发器保存在数据库中,所以我设置了 AdoJobStore 和 “正常”作业它可以正常工作。

现在,我在反序列化数据库通用作业时遇到了问题。我有课:

class DefaultJob<TEventType, TArgsType> : IJob{
 public void Execute(IJobExecutionContext context)
 {
         //do sth
 }
}

使用 RamJobStore 和 DefaultJob 一切正常 - 调度和运行工作。

使用 AdoJobStore 和 DefaultJob 我可以安排,Quartz 将它保存到数据库中(我可以通过 Management Studio 看到它),但是当它尝试从数据库中恢复它时,我得到:

A first chance exception of type 'System.ArgumentException' occurred in mscorlib.dll
A first chance exception of type 'Quartz.JobPersistenceException' occurred in Quartz.dll
A first chance exception of type 'Quartz.JobPersistenceException' occurred in Quartz.dll

我调试了 JobFactory,根本没有调用 NewJob 方法。在它之前发生了一些错误。

有人可以帮忙吗?

【问题讨论】:

    标签: c# generics scheduler quartz.net jobs


    【解决方案1】:

    好的。这个问题很老了。似乎它需要用新数据更新。现在,Quartz.NET 支持通用作业。就这样。问题中的示例现在可以完美运行。

    class DefaultJob<TEventType, TArgsType> : IJob {
        public Task Execute(IJobExecutionContext context)
        { }
    }
    

    【讨论】:

    • 这确实是一个非常古老的问题,但感谢您的更新!;)
    【解决方案2】:

    我在官方 Quartz 邮件列表上转发 Marko Lahma 的答案:

    Quartz.NET 不支持通用作业类型,我觉得它 不应该,因为它可以通过基类轻松表达 具有通用定义,您的每项工作都继承了这个 类,因此定义了泛型类型。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-24
      相关资源
      最近更新 更多