Nanoko / quartznet-mongodb

MongoDB provider for Quartz.NET
41 stars 31 forks source link

JobKey is always null #11

Closed KevinVoell closed 11 years ago

KevinVoell commented 11 years ago

When trying to run this code, it always fails because JobKey is null.

I've checked the DB and its writing the trigger correctly.

        NameValueCollection properties = new NameValueCollection();
        properties["quartz.scheduler.instanceName"] = "MyApplicationScheduler"; // needed if you plan to use the same database for many schedulers
        properties["quartz.scheduler.instanceId"] = System.Environment.MachineName + DateTime.UtcNow.Ticks; // requires uniqueness
        properties["quartz.jobStore.type"] = "Quartz.Impl.MongoDB.JobStore, Quartz.Impl.MongoDB";
        ISchedulerFactory schedulerFactory = new StdSchedulerFactory(properties);
        IScheduler scheduler = schedulerFactory.GetScheduler();
        scheduler.Start();
        IJobDetail job = JobBuilder.Create(typeof(SimpleJob)).WithIdentity("MyJob19", "MyJobGroup").Build();
        ITrigger trigger = TriggerBuilder.Create().WithSchedule(SimpleScheduleBuilder.RepeatSecondlyForTotalCount(10)).StartNow().WithIdentity("MyJobTrigger", "MyJobTriggerGroup").Build();
        scheduler.ScheduleJob(job, trigger);
        Console.ReadKey();
        scheduler.Shutdown(true)
KevinVoell commented 11 years ago

This seems to be related to mongodb driver 1.8.1. Once I rolled back to the 1.7.1 driver this error went away.

andrevdm commented 11 years ago

Any ideas on how to fix for 1.8.1?

andrevdm commented 11 years ago

I've sent a pull request https://github.com/Nanoko/quartznet-mongodb/pull/13 that fixes this for 1.8.1