public void UpdatePlanStatus(PlanUpdateItem item) { try { FilterDefinition <Plan> pf = GetPlanInstanceFilter(item.Plan.UniqueName, item.Plan.InstanceId); item.Plan.LastModified = DateTime.Now.ToString(); _db.GetCollection <Plan>(_hist).FindOneAndReplace(pf, item.Plan, new FindOneAndReplaceOptions <Plan, object>() { IsUpsert = true }); } catch (Exception ex) { PlanItemSingletonProcessor.Instance.Exceptions.Enqueue(ex); if (item.RetryAttempts++ < 5) { PlanItemSingletonProcessor.Instance.Queue.Enqueue(item); } else { PlanItemSingletonProcessor.Instance.Fatal.Enqueue(ex); } } }
public void UpdatePlanStatus(Plan plan) { PlanUpdateItem item = new PlanUpdateItem() { Plan = plan }; if (ProcessPlansOnSingleton) { PlanItemSingletonProcessor.Instance.Queue.Enqueue(item); } else { UpdatePlanStatus(item); } }
void DrainQueue() { while (true) { if (Instance.Queue.Count == 0) { Thread.Sleep(500); //no pending actions available, pause if (_allowExit) { ReadyToExit = true; } continue; } _allowExit = true; PlanUpdateItem item = null; while (Instance.Queue.TryDequeue(out item)) { _dal.UpdatePlanStatus(item); } } }