Пример #1
0
        /// <summary>	Removes a queued item from the pending 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 item. </param>
        /// <returns>	true if it succeeds, false if it fails. </returns>
        /// <exception cref="ObjectDisposedException">	Thrown when the object has been disposed. </exception>
        public bool Complete(TQueue item)
        {
            ThrowIfDisposed();
            var result = _durableJobQueue.Complete(item);

            if (result)
            {
                _onQueueAction.OnNext(DurableJobQueueAction.Completed(item));
            }
            return(result);
        }
Пример #2
0
        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));
                }
            });
        }
Пример #3
0
        protected void ClearAllQueues(IDurableJobQueue <TQueue, TQueuePoison> storage)
        {
            SlideItemsToPending(storage);
            Assert.Empty(storage.GetQueued());

            foreach (var item in storage.GetPending())
            {
                storage.Complete(item);
            }
            Assert.Empty(storage.GetPending());

            foreach (var item in storage.GetPoisoned())
            {
                storage.Delete(item);
            }
            Assert.Empty(storage.GetPoisoned());
        }