简体   繁体   中英

Scheduling generic IJob<> with Quartz .NET and AdoJobStore

I'm developing simple scheduler using Quartz .NET. I want to Quartz persists all of jobs and triggers in database, so I set AdoJobStore and with "normal" jobs it works ok.

Now, I have problem with deserializing from database generic Jobs. I have class:

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

With RamJobStore and DefaultJob<,> everyting is ok - scheduling and running work.

With AdoJobStore and DefaultJob<,> I can schedule, Quartz saves it to database (I can see it via Management Studio), but when it tries to restore it from database, I'm getting:

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

I debuged JobFactory, method NewJob isn't invoked at all. Something wrong happens before it.

Anybody could help?

I am forwarding here the answer from Marko Lahma on official Quartz mailing list:

Quartz.NET does not support generic job types and I feel that it shouldn't as it can be expressed as well easily by having a base class that has the generic definition and your every job just inherits this class and thus defines the generic types.

OK. The question is pretty old. And seems it needs to be updated with new data. Now, Quartz.NET supports generic jobs. That's all. The sample in the question, now works perfectly.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM