michaelklishin / quartz-mongodb

A MongoDB-based store for the Quartz scheduler. This fork strives to be as feature complete as possible. Originally by MuleSoft.
Other
249 stars 203 forks source link

Can't have job with multiple triggers #52

Closed lordbuddha closed 10 years ago

lordbuddha commented 10 years ago

Trying to schedule a job with a second trigger causes (line numbers not reflective of master branch).

org.quartz.ObjectAlreadyExistsException: {....} at com.novemberain.quartz.mongodb.MongoDBJobStore.storeJobInMongo(MongoDBJobStore.java:1093) at com.novemberain.quartz.mongodb.MongoDBJobStore.storeJobAndTrigger(MongoDBJobStore.java:118) at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:840) at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:250)

If the Job already exists, cool, ignore the error and just add the trigger.... There is supposed to be support for a one (job) to many (triggers) relationship here.

Was trying to add the second trigger to test out my DisallowConcurrentExecution support.

lordbuddha commented 10 years ago

Ahh, bug. Need to change

      if (existing && replaceExisting) {
        jobCollection.update(keyDbo, job);
      } else {
        jobCollection.insert(job);
      }

to

      if (existing && replaceExisting) {
        jobCollection.update(keyDbo, job);
      } else if (!existing) {
        jobCollection.insert(job);
      }

Actually, needs more work than that. Will fix.