mongodb-quartz-net
mongodb-quartz-net copied to clipboard
Problem when scheduling many jobs
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);