/// <summary> Poisons an item, moving it from the pending state to the poisoned state. </summary> /// <remarks> /// Should throw an exception if no item exists in the pending state. Delegates to the underlying job queue. Fires a notification on /// OnQueueAction if the operation was a success. /// </remarks> /// <param name="item"> The original item. </param> /// <param name="poisonedItem"> The original item, converted to its poisoned representation. </param> /// <returns> true if it succeeds, false if it fails. </returns> /// <exception cref="ObjectDisposedException"> Thrown when the object has been disposed. </exception> public bool Poison(TQueue item, TQueuePoison poisonedItem) { ThrowIfDisposed(); var result = _durableJobQueue.Poison(item, poisonedItem); if (result) { _onQueueAction.OnNext(DurableJobQueueAction.Poisoned(item, poisonedItem)); } return(result); }
internal JobResultJournalWriter(IObservable <JobResult <TJobInput, TJobOutput> > jobCompletionNotifications, IJobResultInspector <TJobInput, TJobOutput, TQueuePoison> jobResultInspector, IDurableJobQueue <TJobInput, TQueuePoison> durableJobQueue, ILog log, IScheduler scheduler) { if (null == durableJobQueue) { throw new ArgumentNullException("durableJobQueue"); } if (null == jobResultInspector) { throw new ArgumentNullException("jobResultInspector"); } if (null == jobCompletionNotifications) { throw new ArgumentNullException("jobCompletionNotifications"); } this._jobCompleted = jobCompletionNotifications .SubscribeOn(scheduler) .Subscribe(notification => { if (null == notification) { log.Error(CultureInfo.CurrentCulture, m => m("Received invalid NULL Notification<JobResult<{0},{1}>>", typeof(TJobInput).Name, typeof(TJobOutput).Name)); return; } var queueAction = jobResultInspector.Inspect(notification); if (null == queueAction) { log.Error(CultureInfo.CurrentCulture, m => m("Received invalid NULL JobQueueAction<{0}> from Inspect call", typeof(TQueuePoison).Name)); } //no need to check else if (queueAction.ActionType == JobQueueActionType.Poison) { durableJobQueue.Poison(notification.Input, queueAction.QueuePoison); } else if (queueAction.ActionType == JobQueueActionType.Complete) { durableJobQueue.Complete(notification.Input); } else { log.Error(CultureInfo.CurrentCulture, m => m("Received invalid JobQueueAction<{0}> with JobQueueActionType of Unknown", typeof(TQueuePoison).Name)); } }); }