mongodb-quartz-net icon indicating copy to clipboard operation
mongodb-quartz-net copied to clipboard

Problem when scheduling many jobs

Open Arthurrochaa opened this issue 3 years ago • 0 comments

Hi!

When trying to schedule many jobs at the same time, the following exception is bursting and consequently taking a long time to finalize the schedule:

MongoDB.Driver.Core.Operations.MongoBulkWriteOperationException em System.Private.CoreLib.dll

Follow the example of building jobs, the code snippet is inserted in a for loop, assigning the respective keys dynamically:

               var triggersAndJobs = new Dictionary<IJobDetail, IReadOnlyCollection<ITrigger>>();

                var jobBuilder = JobBuilder.Create<Scheduler>()
                    .WithIdentity(jobKey, GroupName)
                    .RequestRecovery(true))
                    .Build();

                var triggerCollection = new List<ITrigger>{ TriggerBuilder.Create()
                    .WithIdentity(triggerKey, GroupName)
                    .StartAt(time.ToUniversalTime())
                    .WithSchedule(SimpleScheduleBuilder.Create().WithMisfireHandlingInstructionFireNow())
                    .Build() };

                triggersAndJobs.Add(job, triggerCollection);
            
                await scheduler.ScheduleJobs(triggersAndJobs, true);

Arthurrochaa avatar Mar 15 '21 20:03 Arthurrochaa