예제 #1
0
        public override async Task AbandonAsync(IQueueItem <TData> item)
        {
            EnsureArg.IsNotNull(item, nameof(item));
            EnsureArg.IsNotNullOrEmpty(item.Id, nameof(item.Id));
            this.logger.LogDebug($"queue item abandon (id={item.Id}, queue={this.options.Name})");

            if (item.IsAbandoned || item.IsCompleted)
            {
                throw new InvalidOperationException($"queue item has already been completed or abandoned (id={item.Id})");
            }

            var message = this.ToMessage(item);

            if (message.DequeueCount > this.options.Retries)
            {
                // too many retries
                await Task.WhenAll(
                    this.queue.DeleteMessageAsync(message),
                    this.deadletterQueue.AddMessageAsync(message)).AnyContext();
            }
            else
            {
                await this.queue.UpdateMessageAsync(message, TimeSpan.Zero, MessageUpdateFields.Visibility).AnyContext(); // item available immediately
            }

            Interlocked.Increment(ref this.abandonedCount);
            item.MarkAbandoned();

            this.logger.LogJournal(LogKeys.Queueing, $"item abandoned (id={item.Id}, queue={this.options.Name}, type={typeof(TData).PrettyName()})", LogEventPropertyKeys.TrackDequeue);
            this.LastDequeuedDate = DateTime.UtcNow;
        }
예제 #2
0
        /// <summary>
        /// Send invoice request to settlement service
        /// </summary>
        /// <param name="queueItem">SettlementQueueItem</param>
        /// <returns>true if invoice request succeeds</returns>
        public override bool ProcessRequest(IQueueItem queueItem)
        {
            Helper.ArgumentNotNull(queueItem, "queueItem");
            var settlementQueueItem = queueItem as SettlementQueueItem;

            if (settlementQueueItem == null)
            {
                Log.LogError("SettlementQueueItem cannot be cast from queue item {0}", null, null,  queueItem);
                return false;
            }

            var transaction = SettlementManager.CreateTransactionModelForInvoiceRequest(settlementQueueItem.BookingId, settlementQueueItem.OrderId, settlementQueueItem.EventId, settlementQueueItem.ForceProcess);

            if (Log.IsDebugEnabled)
            {
                Log.LogDebug(transaction.SerializeToXML());
            }

        var result = transaction != null && ServiceManager.SendStoreInvoiceRequest(transaction);
            if (result == false)
            {
                queueItem.Notes = transaction == null ? "Failed to create transaction item." : 
                                                        "Failed to connect to settlement service.";
            }
            return result;
        }
예제 #3
0
파일: Message.cs 프로젝트: nistec/MQueue
        /// <summary>
        /// Get an instance of <see cref="QueueItemStream"/> from file.
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static ReadFileState ReadFile(string filename, out IQueueItem item)
        {
            if (!File.Exists(filename))
            {
                item = null;
                return(ReadFileState.NotExists);
            }

            try
            {
                NetStream netStream = new NetStream();
                using (Stream input = File.OpenRead(filename))
                {
                    input.CopyTo(netStream);
                }
                netStream.Position = 0;
                QueueItem qitem = new QueueItem(netStream, null);

                item = qitem as IQueueItem;

                return(ReadFileState.Completed);
            }
            catch (IOException ioex)
            {
                //Netlog.Exception("ReadFile IOException ", ioex);
                item = null;
                return(ReadFileState.IOException);
            }
            catch (Exception ex)
            {
                //Netlog.Exception("ReadFile Exception ", ex);
                item = null;
                return(ReadFileState.Exception);
            }
        }
예제 #4
0
        /// <summary>
        /// Enqueue Message
        /// </summary>
        /// <param name="item"></param>
        public IQueueAck Enqueue(IQueueItem item)
        {
            if (this.HoldEnqueue || IsCapacityExceeds())
            {
                //if (CoverMode > CoverMode.None)
                //{
                //    OnCoverHoldItem(item, 0, 0);
                //}
                //Thread.Sleep(m_EnqueueWait);

                return(new QueueAck(MessageState.QueueInHold, item));// Ptr.Get(item,PtrState.QueueInHold);
            }

            while (ISLOCK() > 0)
            {
                Thread.Sleep(100);
            }

            //using (TransactionScope tran = new TransactionScope())
            //{

            var ack = Q.Enqueue(item);

            //if (_Coverable)
            //{
            //    _QCover.Save(item);
            //}
            return(ack);
            //}
        }
예제 #5
0
파일: InMemoryQueue.cs 프로젝트: vip32/Naos
        public override Task CompleteAsync(IQueueItem <TData> item)
        {
            EnsureArg.IsNotNull(item, nameof(item));
            EnsureArg.IsNotNullOrEmpty(item.Id, nameof(item.Id));

            if (item.IsAbandoned || item.IsCompleted)
            {
                throw new InvalidOperationException($"queue item has already been completed or abandoned (id={item.Id})");
            }

#pragma warning disable IDE0067 // Dispose objects before losing scope
#pragma warning disable CA2000  // Dispose objects before losing scope
            if (!this.dequeued.TryRemove(item.Id, out var dequeuedItem) || dequeuedItem == null)
#pragma warning restore CA2000  // Dispose objects before losing scope
#pragma warning restore IDE0067 // Dispose objects before losing scope
            {
                throw new Exception($"unable to remove item from the dequeued list, not found (id={item.Id})");
            }

            Interlocked.Increment(ref this.completedCount);
            item.MarkCompleted();

            this.Logger.LogJournal(LogKeys.Queueing, $"queue item completed: {typeof(TData).PrettyName()} (id={item.Id}, queue={this.Options.QueueName})", LogPropertyKeys.TrackDequeue);
            this.LastDequeuedDate = DateTime.UtcNow;
            return(Task.CompletedTask);
        }
예제 #6
0
        protected override bool TryPeek(Ptr ptr, out IQueueItem item)
        {
            if (CoverMode == CoverMode.Persistent)
            {
                if (CommitMode == CommitMode.OnDisk)
                {
                    if (m_db.TryGetValue(ptr.Identifier, out item))
                    {
                        OnTryPeek(ptr, item, true);
                        return(true);
                    }
                }
                else if (QueueList.TryGetValue(ptr, out item))
                {
                    return(true);
                }
            }
            else if (QueueList.TryGetValue(ptr, out item))
            {
                return(true);
            }


            return(false);
        }
예제 #7
0
        /// <summary>
        /// Process the AIG business request
        /// </summary>
        /// <param name="queueItem">item being processed</param>
        /// <returns>true if successful or payload type not provider, rateplan, roomtype, or room</returns>
        public override bool ProcessRequest(IQueueItem queueItem)
        {
            bool result = true;
            Business.Cache.Cache.PromoCache.Invalidate();
            switch (queueItem.PayloadType)
            {
                case PayloadTypeEnum.Provider:           
                    result = new ProviderChangeProcessor().ProcessChange(queueItem, ref providerSubscriberOptInLookup);
                    break;
                case PayloadTypeEnum.RatePlan:
                    result = new RatePlanChangeProcessor().ProcessChange(queueItem, ref providerSubscriberOptInLookup);
                    break;
                case PayloadTypeEnum.RoomType:
                    result = new RoomTypeChangeProcessor().ProcessChange(queueItem, ref providerSubscriberOptInLookup);
                    break;
                case PayloadTypeEnum.Room:
                    result = new RoomChangeProcessor().ProcessChange(queueItem, ref providerSubscriberOptInLookup);
                    break;
            }

            if (result == false)
            {
                queueItem.Notes = "Failed to process change via AIG service call.";
            }
            return result;
        }
 public void AddItem(IQueueItem item)
 {
     try
     {
         base.Insert(item as QueueItem);
     }
     catch (MongoWriteException ex)
     {
         if (ex.InnerException is MongoBulkWriteException innerException)
         {
             if (innerException.WriteErrors.All(code => code.Code == 11000))
             {
                 // duplicate key error collection, ignoring
             }
             else
             {
                 throw;
             }
         }
         else
         {
             throw;
         }
     }
 }
예제 #9
0
 public void Save(IQueueItem item)
 {
     try
     {
         if (CoverProvider == CoverProviders.File)
         {
             string filename = GetFilename(item.Identifier);
             var    stream   = item.BodyStream;
             stream.SaveToFile(filename);
         }
         if (CoverProvider == CoverProviders.Sqlite)
         {
             PersistentQueue bag = new PersistentQueue(dbSettings);
             bag.AddOrUpdate
             //var dt = DbLite.MessageToDataTable(message);
             //using (Nistec.Data.Sqlite.DbLite db = new Nistec.Data.Sqlite.DbLite(CoverPath))
             //{
             //    db.ExecuteNonQuery("",)
             //    //bulk.BulkInsert(dt, CoverTableName, ConnectTimeout, null);
             //}
         }
         else
         {
             //ExecCover(((QueueItemStream)item).Copy());
             ExecCover((QueueItemStream)item);
         }
     }
     catch (Exception ex)
     {
         QLog.Exception("QCover.Save ", ex);
     }
 }
예제 #10
0
        /// <summary>
        /// Process Room Type Changes
        /// </summary>
        /// <param name="queueItem">Queue Item</param>
        /// <param name="providerSubscriberOptInLookup">Provider Subscriber Opt In list</param>
        public bool ProcessChange(IQueueItem queueItem, ref ProviderSubscriberOptInsLookup providerSubscriberOptInLookup)
        {
            var roomTypeChange = XmlSerialization.XmlDeserializeFromString<PushRoomTypeUpdate>(queueItem.Payload);
            var providerId = roomTypeChange.BusinessId.ToGuid();
            var roomTypeId = roomTypeChange.RoomTypeId.ToGuid();

            RoomTypeChangeMessage roomTypeChangeMessage;
            RoomTypeChangeType roomTypeChangeType;
            Enum.TryParse(roomTypeChange.Action, out roomTypeChangeType);

            switch (roomTypeChangeType)
            {
                case RoomTypeChangeType.AddRoomType:
                    roomTypeChangeMessage = new RoomTypeChangeMessage(providerId, roomTypeId, ChangeType.Insert, RoomTypeChangeMessage.RoomTypeChangeType.Full);
                    break;
                case RoomTypeChangeType.ModifyRoomType:
                    roomTypeChangeMessage = new RoomTypeChangeMessage(providerId, roomTypeId, ChangeType.Update, RoomTypeChangeMessage.RoomTypeChangeType.Attribute);
                    break;
                case RoomTypeChangeType.DeleteRoomType:
                    roomTypeChangeMessage = new RoomTypeChangeMessage(providerId, roomTypeId, ChangeType.Delete, RoomTypeChangeMessage.RoomTypeChangeType.Full);
                    break;
                default:
                    return false;
            }

            bool isSuccess = true;

            foreach (var messagingIntegratorService in CreateServices(roomTypeChangeMessage))
            {
               isSuccess &= messagingIntegratorService.ProcessAndQueueChangeUpdates(providerSubscriberOptInLookup, roomTypeChangeMessage);
            }

            return isSuccess;
        }
예제 #11
0
        public static TransStream DoResponse(IQueueItem item, MessageState state)
        {
            if (item == null)
            {
                return(null);
                //throw new MessageException(MessageState.MessageError, "Invalid queue item to write response");
            }

            var ts = ((QueueItem)item).ToTransStream(state);

            //((QueueItem)item).SetState(state);
            QLogger.Debug("QueueController DoResponse IQueueAck: {0}", item.Print());
            //return item.ToStream();

            return(ts);

            //if (item != null)
            //{
            //    ((QueueItem)item).SetState(state);
            //    return item.GetItemStream();
            //}
            //else
            //{
            //    Message response = Message.Ack(MessageState.UnExpectedError, new MessageException(MessageState.UnExpectedError, "WriteResponse error: there is no item stream to write reponse"));
            //    return response.ToStream();
            //}

            // QLogger.DebugFormat("Server WriteResponse State:{0}, MessageId: {1}", item.MessageState, item.MessageId);
        }
예제 #12
0
        private IQueueItem ReceiveItemWorker(TimeSpan timeout, object state)
        {
            IQueueItem item = null;
            TimeOut    to   = new TimeOut(timeout);

            while (item == null)
            {
                if (to.IsTimeOut())
                {
                    state = (int)ReceiveState.Timeout;
                    break;
                }
                item = Dequeue();// this.Receive();
                if (item == null)
                {
                    Thread.Sleep(100);
                }
            }
            if (item != null)
            {
                state = (int)ReceiveState.Success;
                Console.WriteLine("Dequeue item :{0}", item.Identifier);
            }
            return(item);
        }
예제 #13
0
        public void Enqueue(IQueueItem item)
        {
            lock (_lock)
            {
                if (!(item is IPriorityItem))
                {
                    throw new ArgumentException("Cant enqueue item into priority queue. Argument should be IPriorityItem");
                }
                var pri = (item as IPriorityItem).Priority;
                if (pri == Priority.None)
                {
                    pri = Priority.Pri7;
                }

                if ((int)pri > _highestPri)
                {
                    _highestPri = (int)pri;
                }
                if ((int)pri < _lowestPri)
                {
                    _lowestPri = (int)pri;
                }

                Count++;

                _storage[pri].Enqueue((IPriorityItem)item);
            }
        }
예제 #14
0
        /// <summary>
        /// Thos method used to publish event and handle exception, if happened
        /// </summary>
        /// <param name="item"></param>
        protected virtual void onProcessQueueItem(IQueueItem item)
        {
            MethodInfo genericMethod = GetPublishMethodInfo(item.DeclaringEventType);
            object     typedEvent    = BuildGenericQueueEvent(item);
            object     sender        = BuildSender(item.DeclaringEventType);

            try
            {
                genericMethod.Invoke(_eventBusService, new[] { typedEvent, sender });
                onEventHandled(item);
            }
            // Exceptions from actual delegate are wrapped into TargetInvocationException by MethodBase.Invoke()
            catch (TargetInvocationException ex)
            {
                RetryNeededException retry = ex.InnerException as RetryNeededException;
                if (retry != null)
                {
                    onEventRetried(item, retry);
                }
                else
                {
                    onEventFailed(item, ex.InnerException);
                }
            }
        }
예제 #15
0
        protected override IQueueItem GetFirstItem()
        {
            IQueueItem item = null;

            try
            {
                item = base.Dequeue();
                if (item != null)
                {
                    IPersistItem qi;
                    m_db.TryRemove(item.Identifier, out qi);
                }

                //return m_db.Dequeue(this.Host);


                //if (Count() > 0)
                //{

                //    foreach (object o in QueueList.Keys)
                //    {
                //        item = Dequeue((Guid)o);
                //        if (item != null)
                //        {
                //            break;
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(item);
        }
예제 #16
0
파일: Channel.cs 프로젝트: nistec/MQueue
        protected override void OnReceiveCompleted(ReceiveCompletedEventArgs e)
        {
            base.OnReceiveCompleted(e);

            IQueueItem item = e.Item;

            if (item == null)
            {
                return;
            }

            if (e.AsyncResult.IsCompleted)
            {
                base.CommitTrans(e.Item.ItemId, item.HasAttach);
            }
            Console.WriteLine("Queue{0} Items count: {1}", QueueName, base.Count);
            //MControl.Messaging.Netlog.InfoFormat("Queue{0} Items count: {1}", QueueName, base.Count);
            if (item != null)
            {
                Console.WriteLine("Queue{0} ReceiveCompleted: {1} ,thread{2}, Duration:{3}", base.QueueName, e.Item.ItemId, Thread.CurrentThread.Name, e.Item.Duration());
            }
            else
            {
                Console.WriteLine("Queue{0} Receive timeout ,thread{1}", base.QueueName, Thread.CurrentThread.Name);
            }
            if (base.Count <= 0)
            {
                TimeSpan ts = DateTime.Now.Subtract(start);
                Console.WriteLine("Time took:{0}", ts.TotalSeconds);
            }

            base.AfterReceiveCompleted();
        }
예제 #17
0
파일: Channel.cs 프로젝트: nistec/MQueue
        protected override void OnMessageReceived(QueueItemEventArgs e)
        {
            base.OnMessageReceived(e);
            IQueueItem item = e.Item;

            if (item == null)
            {
                return;
            }

            if (e.State == ItemState.Dequeue)
            {
                base.CommitTrans(item.ItemId, item.HasAttach);
            }
            Console.WriteLine("Queue{0} Items count: {1}", QueueName, base.Count);
            if (item != null)
            {
                Console.WriteLine("Queue{0} MessageReceived: {1}, Duration:{2}", QueueName, item.ItemId, item.Duration());
            }
            else
            {
                Console.WriteLine("Queue{0} Receive timeout", QueueName);
            }

            Netlog.InfoFormat("OnMessageReceived:{0} Received:{1}", e.Item.MessageId, e.Item.SentTime);

            if (base.Count <= 0)
            {
                TimeSpan ts = DateTime.Now.Subtract(start);
                Console.WriteLine("Time took:{0}", ts.TotalSeconds);
            }
        }
예제 #18
0
        private void ProcessItems(Func <IQueueItem <TData>, CancellationToken, Task> handler, bool autoComplete, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(handler, nameof(handler));
            var linkedCancellationToken = this.CreateLinkedTokenSource(cancellationToken);

#pragma warning disable CA2016 // Forward the 'CancellationToken' parameter to methods that take one
            Task.Run(async() =>
            {
                this.Logger.LogInformation($"{{LogKey:l}} processing started (queue={this.Options.QueueName}, type={this.GetType().PrettyName()})", args: new[] { LogKeys.Queueing });
                while (!linkedCancellationToken.IsCancellationRequested)
                {
                    IQueueItem <TData> item = null;
                    try
                    {
                        item = await this.DequeueWithIntervalAsync(linkedCancellationToken.Token).AnyContext();
                    }
                    catch (Exception ex)
                    {
                        this.Logger.LogError(ex, $"{{LogKey:l}} processing error: {ex.Message}", args: new[] { LogKeys.Queueing });
                    }

                    if (linkedCancellationToken.IsCancellationRequested || item == null)
                    {
                        await Task.Delay(this.Options.ProcessInterval, linkedCancellationToken.Token).AnyContext();
                        continue;
                    }

                    using (this.Logger.BeginScope(new Dictionary <string, object>
                    {
                        [LogPropertyKeys.CorrelationId] = item.CorrelationId,
                    }))
                        using (var scope = this.Options.Tracer?.BuildSpan($"dequeue {this.Options.QueueName}", LogKeys.Queueing, SpanKind.Consumer, new Span(item.TraceId, item.SpanId)).Activate(this.Logger))
                        {
                            try
                            {
                                await handler(item, linkedCancellationToken.Token).AnyContext();
                                if (autoComplete && !item.IsAbandoned && !item.IsCompleted)
                                {
                                    await item.CompleteAsync().AnyContext();
                                }
                            }
                            catch (Exception ex)
                            {
                                Interlocked.Increment(ref this.workerErrorCount);
                                scope.Span.SetStatus(SpanStatus.Failed, ex.GetFullMessage());
                                this.Logger.LogError(ex, $"{{LogKey:l}} queue processing failed: {ex.GetFullMessage()}", args: new[] { LogKeys.Queueing });

                                if (!item.IsAbandoned && !item.IsCompleted)
                                {
                                    await item.AbandonAsync().AnyContext();
                                }
                            }
                        }
                }

                this.Logger.LogDebug($"{{LogKey:l}} queue processing exiting (name={this.Options.QueueName}, cancellation={linkedCancellationToken.IsCancellationRequested})", LogKeys.Queueing);
            }, linkedCancellationToken.Token)
            .ContinueWith(t => linkedCancellationToken.Dispose());
#pragma warning restore CA2016 // Forward the 'CancellationToken' parameter to methods that take one
        }
예제 #19
0
        public void Enqueue(IQueueItem item)
        {
            lock (_lock)
            {
                if (!(item is IPriorityItem))
                {
                    throw new ArgumentException("Cant enqueue item into priority queue. Argument should be IPriorityItem");
                }
                var pri = (item as IPriorityItem).Priority;
                if (pri == Priority.None)
                    pri = Priority.Pri7;

                if ((int) pri > _highestPri)
                {
                    _highestPri = (int) pri;
                }
                if ((int) pri < _lowestPri)
                {
                    _lowestPri = (int) pri;
                }

                Count++;

                _storage[pri].Enqueue((IPriorityItem)item);
            }
        }
예제 #20
0
        public override Task AbandonAsync(IQueueItem <TData> item)
        {
            EnsureArg.IsNotNull(item, nameof(item));
            EnsureArg.IsNotNullOrEmpty(item.Id, nameof(item.Id));
            this.Logger.LogDebug($"{{LogKey:l}} queue item abandon (id={item.Id}, queue={this.Options.QueueName})", LogKeys.Queueing);

            if (item.IsAbandoned || item.IsCompleted)
            {
                throw new InvalidOperationException($"queue item has already been completed or abandoned (id={item.Id})");
            }

            var tag = item.Properties.GetValueOrDefault <ulong>("DeliveryTag");

            if (tag > 0)
            {
                this.channel.BasicNack(tag, false, false);
                Interlocked.Increment(ref this.abandonedCount);
                item.MarkAbandoned();

                this.Logger.LogJournal(LogKeys.Queueing, $"queue item abandoned: {typeof(TData).PrettyName()} (id={item.Id}, queue={this.Options.QueueName})", LogPropertyKeys.TrackDequeue);
                this.LastDequeuedDate = DateTime.UtcNow;
            }

            return(Task.CompletedTask);
        }
예제 #21
0
        /// <summary>
        /// Peek Message
        /// </summary>
        /// <returns></returns>
        public IQueueItem Peek(Ptr ptr)
        {
            IQueueItem item = null;

            TryPeek(ptr, out item);
            return(item);
        }
예제 #22
0
        /// <summary>
        /// Process Rate Plan Changes
        /// </summary>
        /// <param name="queueItem">Queue Item</param>
        /// <param name="providerSubscriberOptInLookup">Provider Subscriber Opt In list</param>
        public bool ProcessChange(IQueueItem queueItem, ref ProviderSubscriberOptInsLookup providerSubscriberOptInLookup)
        {
            var ratePlanChange = XmlSerialization.XmlDeserializeFromString<PushRatePlanUpdate>(queueItem.Payload);
            ChangeType changeType;
            RatePlanChangeType ratePlanChangeType;
            Enum.TryParse(ratePlanChange.Action, out ratePlanChangeType);

            switch (ratePlanChangeType)
            {
                //adding of a new rate plan will create a new roomtype in the Handle - this is because every RoomType/RatePlan combination is treated as a Product Type in Expedia
                case RatePlanChangeType.AddRatePlan:
                    changeType = ChangeType.Insert;                    
                    break;
                case RatePlanChangeType.ModifyRatePlan:
                    changeType = ChangeType.Update;
                    break;
                case RatePlanChangeType.DeleteRatePlan:
                    changeType = ChangeType.Delete;
                    break;
                default:
                    return false;
            }

            var ratePlanChangeMessage = new RatePlanChangeMessage(ratePlanChange.BusinessId.ToGuid(), changeType, Helper.GetProductGuid(ratePlanChange.RoomTypeId, ratePlanChange.RatePlanId), ratePlanChange.StartDate, ratePlanChange.EndDate);

            bool isSuccess = true;

            foreach (var messagingIntegratorService in CreateServices(ratePlanChangeMessage))
            {
                isSuccess &= messagingIntegratorService.ProcessAndQueueChangeUpdates(providerSubscriberOptInLookup, ratePlanChangeMessage);
            }

            return isSuccess;
        }
예제 #23
0
파일: Program.cs 프로젝트: nistec/MQueue
        static void rq_MessageArraived(object sender, QueueItemEventArgs e)
        {
            IAsyncQueue rq   = (IAsyncQueue)sender;
            IQueueItem  item = rq.Dequeue();

            Console.WriteLine("MessageArraived: " + item.ItemId);
        }
예제 #24
0
        protected override IQueueItem GetFirstItem()
        {
            IQueueItem item = null;

            try
            {
                var items = m_fm.DequeueItems(FileOrderTypes.ByName, 1);
                if (items != null)
                {
                    item = items[0];
                }

                //if (Count() > 0)
                //{

                //    foreach (object o in QueueList.Keys)
                //    {
                //        item = Dequeue((Guid)o);
                //        if (item != null)
                //        {
                //            break;
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                QLog.Exception("GetFirstItem file error: ", ex, true, true);
                return(null);
            }
            return(item);
        }
예제 #25
0
        protected override IQueueItem GetFirstItem()
        {
            IQueueItem item = null;

            try
            {
                return(m_db.Dequeue(this.Host));


                //if (Count() > 0)
                //{

                //    foreach (object o in QueueList.Keys)
                //    {
                //        item = Dequeue((Guid)o);
                //        if (item != null)
                //        {
                //            break;
                //        }
                //    }
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(item);
        }
예제 #26
0
 /// <summary>
 /// Adds new item to the queue.
 /// </summary>
 /// <param name="item">The item to add.</param>
 internal void Add(IQueueItem item)
 {
     lock (this)
     {
         _queueItems.Add(item);
     }
 }
예제 #27
0
        protected override IQueueItem GetFirstItem()
        {
            IQueueItem item = null;

            try
            {
                if (Count() > 0)
                {
                    //var k= QueueList.Keys.FirstOrDefault<Guid>();
                    //return Dequeue(k);

                    foreach (var g in QueueList.Keys)
                    {
                        item = Dequeue(g);
                        if (item != null)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(item);
        }
예제 #28
0
        public void ReportAsync(QueueCmdReport command, string host, Action <IQueueItem> action)
        {
            using (

                Task <IQueueItem> task = Task <IQueueItem> .Factory.StartNew(() =>
                                                                             Report(command, host)
                                                                             ,
                                                                             canceller.Token,
                                                                             TaskCreationOptions.LongRunning,
                                                                             TaskScheduler.Default))
            {
                task.Wait();
                if (task.IsCompleted)
                {
                    IQueueItem item = task.Result;
                    if (item != null)
                    {
                        if (action != null)
                        {
                            Task.Factory.StartNew(() => action(item));
                        }
                    }
                }
                else if (task.IsCanceled)
                {
                }
                else if (task.IsFaulted)
                {
                }
            }
        }
예제 #29
0
        protected override bool TryDequeue(Ptr ptr, out IQueueItem item)
        {
            if (CoverMode == CoverMode.Persistent)
            {
                if (QueueList.TryRemove(ptr, out item))
                {
                    if (CommitMode == CommitMode.OnDisk)
                    {
                        IQueueItem item_pers = null;
                        if (m_db.TryRemove(ptr.Identifier, out item_pers))
                        {
                            OnTryDequeue(ptr, item, true);
                            return(true);
                        }
                    }
                    else
                    {
                        return(PersistItemRemove(ptr));
                    }
                }
            }
            else
            {
                if (QueueList.TryRemove(ptr, out item))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #30
0
        //public void RequestCompleted(IAsyncResult asyncResult)
        //{
        //    OnReceiveCompleted(new ReceiveCompletedEventArgs(this, asyncResult));
        //}

        private IQueueItem ReceiveItemWorker(TimeSpan timeout, object state)
        {
            if (this.HoldDequeue)
            {
                return(null);
            }
            DateTime startReceive = DateTime.Now;

            IQueueItem item = null;


            while (item == null)
            {
                if (timeout < DateTime.Now.Subtract(startReceive))
                {
                    //TODO: raise event
                    state = ReceiveState.Timeout;
                    break;
                }
                item = Dequeue();
                if (item == null)
                {
                    Thread.Sleep(m_DequeueWait);
                }
            }
            if (item != null)
            {
                state = ReceiveState.Success;
            }

            //Console.WriteLine("Dequeue item :{0}", item.ItemId);
            return(item);//.Copy() as IQueueItem;
        }
예제 #31
0
        protected override bool TryAdd(Ptr ptr, IQueueItem item)
        {
            var copy = item.Copy();

            QueueList[ptr] = copy;

            if (CoverMode == CoverMode.Persistent)
            {
                if (CommitMode == CommitMode.OnDisk)
                {
                    if (m_db.TryAdd(ptr.Identifier, copy))
                    {
                        OnTryAdd(ptr, item, true);
                        return(true);
                    }
                }
                else //if (CommitMode == CommitMode.OnMemory)
                {
                    return(PersistItemAdd(ptr, copy));
                }
                return(false);
            }
            else //if (CommitMode == CommitMode.OnMemory)
            {
                return(true);
            }
        }
예제 #32
0
        private void ProcessItems()
        {
            ExecutionEngine.EventLogger.Write("QueueProcessingThread:ProcessItems");
            try
            {
                while (IsCallerThreadAlive())
                {
                    while (!_isStopped)
                    {
                        IQueueItem currentItem = GetNextQueuedItem();

                        if (!_isStopped && currentItem != null && IsCallerThreadAlive())
                        {
                            currentItem.Process();
                        }
                        else
                        {
                            _isStopped = true;
                        }
                    }

                    _processStopped.Set();
                    _startGetting.WaitOne(WaitInterval, false);

                    ExecutionEngine.EventLogger.Write("QueueProcessingThread:ProcessItems:1");
                }
            }
            catch (Exception e)
            {
                ExecutionEngine.EventLogger.WriteExceptionInfo(e);
                throw;
            }

            ExecutionEngine.EventLogger.Write("QueueProcessingThread:ProcessItem:2");
        }
예제 #33
0
 public void Remove(IQueueItem item)
 {
     lock (modelLocker)
     {
         model.BasicAck(item.Id, false);
     }
 }
예제 #34
0
        /// <summary>
        /// Enqueue Message
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        internal void ReEnqueue(IQueueItem item)
        {
            Ptr ptr = new Ptr(item, Host);

            switch (item.Priority)
            {
            case Priority.High:
                highQ.Enqueue(ptr);
                break;

            case Priority.Medium:
                mediumQ.Enqueue(ptr);
                break;

            default:
                normalQ.Enqueue(ptr);
                break;
            }

            //if (MessageArrived != null)
            //{
            //    OnMessageArrived(new QueueItemEventArgs(item, MessageState.Arrived));
            //}
            //return new QueueAck(MessageState.Arrived, item);// new Ptr(ptr, PtrState.Arrived);
        }
예제 #35
0
        public void SendSync(IQueueItem message)
        {
            var queueMessage = GetContentAsQueueItem(message);
            var content      = JsonConvert.SerializeObject(queueMessage);

            GetQueue().AddMessage(new CloudQueueMessage(content));
        }
예제 #36
0
 /// <summary>
 /// Marked item as process/complete in the queue
 /// </summary>
 /// <param name="queueItem">Implementer of IQueue</param>
 public void ProcessQueueItem(IQueueItem queueItem)
 {
     if (queueItem == null)
     {
         throw new ArgumentNullException("queueItem");
     }
     ServiceProxyManager.Execute<ServiceClient<IQueueSystem>, IQueueSystem>(proxy =>
       proxy.Proxy.ProcessItem(queueUserId, queueItem.Id.Value));
 }
예제 #37
0
 /// <summary>
 /// Process the AIG request
 /// </summary>
 /// <param name="queueItem">item to be processed</param>
 /// <returns>true if successful</returns>
 public override bool ProcessRequest(IQueueItem queueItem)
 {
     var result = new InventoryChangeProcessor().ProcessChange(queueItem, ref providerSubscriberOptInLookup);
     if (result == false)
     {
         queueItem.Notes = "Failed to process change via AIG service call.";
     }
     return result;
 }
예제 #38
0
        /// <summary>
        /// Process Booking Changes
        /// </summary>
        /// <param name="queueItem">Queue Item</param>
        /// <param name="providerSubscriberOptInLookup">Provider Subscriber Opt In list</param>
        public bool ProcessChange(IQueueItem queueItem, ref ProviderSubscriberOptInsLookup providerSubscriberOptInLookup)
        {
            var inventoryChange = XmlSerialization.XmlDeserializeFromString<PushInventoryUpdate>(queueItem.Payload);
            ChangeType changeType;
            InventoryChangeType inventoryChangeType;
            Enum.TryParse(inventoryChange.Action, out inventoryChangeType);
            DateTime endDate;

            switch (inventoryChangeType)
            {
                case InventoryChangeType.NewBooking:
                case InventoryChangeType.NewCloseout:
                case InventoryChangeType.NewPeriodCloseout:
                    changeType = ChangeType.Insert;
                    break;
                case InventoryChangeType.CancelBooking:
                case InventoryChangeType.CancelCloseout:
                case InventoryChangeType.CancelPeriodCloseout:
                    changeType = ChangeType.Delete;
                    break;
                default:
                    return false;
            }


            DateTime startDate = InventoryChangeMessage.GetValidStartDate(inventoryChange.StartDate);

            //for the booking/closeout update message to AIG, need to specify the date range that is booked out inclusively. This is not the checkin and checkout dates passed
            //in as parameters, but the start dates date, and the end date - 1 days date.
            //eg a 1 day booking for 12/09/2008 should have start date 12/09/2008 and end date 12/09/2008 instead of an end date 13/09/2008   
            //this does not apply to Period Closeouts as the dates are already sent through inclusively
            if (inventoryChangeType != InventoryChangeType.NewPeriodCloseout && inventoryChangeType != InventoryChangeType.CancelPeriodCloseout)
            {
                endDate = InventoryChangeMessage.GetValidEndDate(inventoryChange.StartDate, inventoryChange.EndDate);
            }
            else
            {
                endDate = inventoryChange.EndDate;
            }

            var inventoryChangeMessage = InventoryChangeMessage.IsValidDate(endDate) ? new InventoryChangeMessage(inventoryChange.BusinessId.ToGuid(), changeType, inventoryChange.RoomId.ToGuid(ROOM_PREFIX), startDate, endDate, inventoryChange.RoomTypeId) : null;

            if (inventoryChangeMessage == null)
            {
                return false;
            }
        
            bool isSuccess = true;

            foreach (var messagingIntegratorService in CreateServices(inventoryChangeMessage))
            {
                isSuccess &= messagingIntegratorService.ProcessAndQueueChangeUpdates(providerSubscriberOptInLookup, inventoryChangeMessage);
            }
            return isSuccess;

        }
예제 #39
0
 public void Enqueue(IQueueItem item)
 {
     lock (_lock)
     {
         if (!(item is IPriorityItem))
         {
             throw new ArgumentException("Cant enqueue item into priority queue. Argument should be IPriorityItem");
         }
         var priItem = item as IPriorityItem;
         _storage.Add(priItem);
         _storage = _storage.OrderByDescending(priorityItem => priorityItem.Priority).ToList();
     }
 }
예제 #40
0
        public override bool ProcessRequest(IQueueItem queueItem)
        {
            switch (queueItem.PayloadType)
            {
                case PayloadTypeEnum.PushNotificationBooking:
                    {
                        var bookingId = int.Parse(queueItem.Key);
                        return pushNotificationManager.SendBookingNotification(bookingId, GetActionKeyForMobile(queueItem.Payload));                        
                    }
            }

            return false;
        }
예제 #41
0
        /// <summary>
        /// Validate business change request
        /// </summary>
        /// <param name="queueItem">SettlementQueueItem</param>
        /// <returns>true if invoice request is valid</returns>
        public override bool ValidateRequest(IQueueItem queueItem)
        {
            Helper.ArgumentNotNull(queueItem, "queueItem");
            var settlementQueueItem = queueItem as SettlementQueueItem;

            if (settlementQueueItem == null)
            {
                Log.LogError("SettlementQueueItem cannot be cast from queue item  {0}", null, null,  queueItem);
                return false;
            }

            return SettlementManager.IsBusinessChangeRequestValid(settlementQueueItem.BusinessId);
        }
예제 #42
0
        /// <summary>
        /// Validate invoice request
        /// </summary>
        /// <param name="queueItem">SettlementQueueItem</param>
        /// <returns>true if invoice request is valid</returns>
        public override bool ValidateRequest(IQueueItem queueItem)
        {
            Helper.ArgumentNotNull(queueItem, "queueItem");
            var settlementQueueItem = queueItem as SettlementQueueItem;

            if (settlementQueueItem == null)
            {
                Log.LogError("SettlementQueueItem cannot be cast from queue item  {0}", null, null,  queueItem);
                return false;
            }

            return SettlementManager.IsInvoiceRequestValid(settlementQueueItem.BookingId, settlementQueueItem.OrderId, settlementQueueItem.OrderSourceCode);
        }
예제 #43
0
        /// <summary>
        /// Get item from queue
        /// </summary>
        /// <param name="queueItem">Implementer of IQueueItem</param>
        /// <returns>Implementer of IQueueItem</returns>
        public IQueueItem GetQueueItem(IQueueItem queueItem)
        {
            if (queueItem == null)
            {
                throw new ArgumentNullException("queueItem");
            }

            QueueDataContract.QueueItem dataQueueItem = null;
            ServiceProxyManager.Execute<ServiceClient<IQueueSystem>, IQueueSystem>(proxy =>
                dataQueueItem = proxy.Proxy.GetItem(queueUserId, queueItem.QueueCode.GetCode()));

            return dataQueueItem != null ? CreateQueueItemBasedOnPayloadType(dataQueueItem, queueItem) : null;
        }
예제 #44
0
        public void Enqueue(IQueueItem item)
        {
            queueLock.EnterWriteLock();

            try
            {
                if (!Queue.Any(x => x.Urls == item.Urls) &&
                    (ItemBeingProcessed == null || ItemBeingProcessed.Urls != item.Urls))
                    Queue.Enqueue(item);
            }
            finally
            {
                queueLock.ExitWriteLock();
            }
        }
 private async Task<bool> ProcessQueueItem(IQueueItem<SavedUrlQueueItem> queueItem, Action<bool> backoffResultAction)
 {
     if (queueItem == null)
     {
         backoffResultAction(false);
         return false;
     }
     SavedUrlQueueItem item = null;
     try
     {
         item = queueItem.Item;
         SavedUrl savedUrl = await _savedUrlTable.GetAsync(item.UserId, item.Url.Base64Encode());
         if (savedUrl != null)
         {
             await Task.WhenAll(new[]
             {
                 _userTagService.ProcessTags(savedUrl.UserId, savedUrl.Url, savedUrl.SavedAt, savedUrl.Tags),
                 _urlStatisticsService.IncrementNumberOfSaves(savedUrl.Url),
                 _urlService.CreateIndexOfUserForUrl(savedUrl.Url, item.UserId)
             });
         }
         else
         {
             await _logger.Warning(String.Format("Unable to find saved url userid:{0} url:{1}", item.UserId, item.Url));
         }
         return true;
     }
     catch (Exception ex)
     {
         if (queueItem.DequeueCount >= MaxDequeues && item != null)
         {
             _logger.Error("Unable to process queue item after multiple attempts. Giving up and attempting to place on poison queue for manual attention / later requeueing.", ex).Wait();
             try
             {
                 _poisonQueue.EnqueueAsync(item).Wait(TimeSpan.FromSeconds(30));
             }
             catch
             {
                 // swallow any problem here, storage is likely dying around us
             }
         }
         return queueItem.DequeueCount >= MaxDequeues;
     }
     finally
     {
         backoffResultAction(true);
     }
 }
예제 #46
0
        /// <summary>
        /// Process Room Changes
        /// </summary>
        /// <param name="queueItem">Queue Item</param>
        /// <param name="providerSubscriberOptInLookup">Provider Subscriber Opt In list</param>
        public bool ProcessChange(IQueueItem queueItem, ref ProviderSubscriberOptInsLookup providerSubscriberOptInLookup)
        {
            var roomChange = XmlSerialization.XmlDeserializeFromString<PushRoomUpdate>(queueItem.Payload);
            ChangeType changeType;
            RoomChangeType roomChangeType;
            Enum.TryParse(roomChange.Action, out roomChangeType);

            //all these actions trigger Handle with a RoomTypeConfigurationUpdate message but i think its still valid to differentiate them in case we need it in the future
            switch (roomChangeType)
            {
                case RoomChangeType.AddRoom:
                    changeType = ChangeType.Insert;
                    break;
                case RoomChangeType.ModifyRoom:
                    //if we cant view the room online or it is not active then remove it
                    if (!roomChange.IsAvailableOnline || !roomChange.IsActive)
                    {
                        changeType = ChangeType.Delete;
                    }
                    else
                    {
                        changeType = ChangeType.Update;                        
                    }                    
                    break;
                case RoomChangeType.DeleteRoom:
                    changeType = ChangeType.Delete;
                    break;
                default:
                    return false;
            }

            var roomChangeMessage = new RoomChangeMessage(roomChange.BusinessId.ToGuid(), changeType, roomChange.RoomTypeId.ToGuid(ROOM_TYPE_PREFIX), roomChange.RoomId.ToGuid(ROOM_PREFIX));

            bool isSuccess = true;

            foreach (var messagingIntegratorService in CreateServices(roomChangeMessage))
            {
                isSuccess &= messagingIntegratorService.ProcessAndQueueChangeUpdates(providerSubscriberOptInLookup,
                                                                         roomChangeMessage);
            }

            return isSuccess;
        }
예제 #47
0
        /// <summary>
        /// Send business change request to settlement service
        /// </summary>
        /// <param name="queueItem">SettlementQueueItem</param>
        /// <returns>true if invoice request succeeds</returns>
        public override bool ProcessRequest(IQueueItem queueItem)
        {
            Helper.ArgumentNotNull(queueItem, "queueItem");
            var settlementQueueItem = queueItem as SettlementQueueItem;

            if (settlementQueueItem == null)
            {
                Log.LogError("SettlementQueueItem cannot be cast from queue item {0}", null, null,  queueItem);
                return false;
            }

            var provider = SettlementManager.CreateNewProviderModelForBusinessChange(settlementQueueItem.BusinessId);
            var result = provider != null && ServiceManager.SendStoreBusinessChangeRequest(provider);
            if (result == false)
            {
                queueItem.Notes = provider == null ? "Failed to create provider item." :
                                                     "Failed to connect to settlement service.";
            }

            return result;
        }
 internal LargeMessageQueueException(string message, Exception innerException, IQueueItem<LargeMessageReference> queueItem) : base(message, innerException)
 {
     _queueItem = queueItem;
 }
예제 #49
0
 /// <summary>
 /// Marked item as process/complete in the queue
 /// </summary>
 /// <param name="queueItem">Implementer of IQueue</param>
 public virtual void ProcessQueueItem(IQueueItem queueItem)
 {
     queueProcessor.ProcessQueueItem(queueItem);
 }
예제 #50
0
 /// <summary>
 /// Called once for each item to validate the queue item for this task
 /// </summary>
 /// <param name="queueItem">queue item to be processed</param>
 /// <returns>true if valid item</returns>
 public abstract bool ValidateRequest(IQueueItem queueItem);
예제 #51
0
 /// <summary>
 /// No validation for AIG requests done at this time
 /// </summary>
 /// <remarks>
 /// Should check correctly
 /// </remarks>
 /// <param name="queueItem">item being validated</param>
 /// <returns>true</returns>
 public override bool ValidateRequest(IQueueItem queueItem)
 {
     return true;
 }
예제 #52
0
 public void Add(IQueueItem item)
 {
     Queue.Add(item);
     if (!_worker.IsBusy)
         _worker.RunWorkerAsync();
 }
예제 #53
0
        protected void ProcessQueuedItem()
        {
            var key = Guid.Empty;
            IQueueItem itemToReduce = null;
            if (!reductionRepository.HasLoadedSavedEntries)
                return;
            try
            {
                queueLock.EnterWriteLock();

                try
                {
                    if (queue.Count > 0)
                        itemToReduce = queue.Dequeue();
                }
                finally
                {
                    queueLock.ExitWriteLock();
                }

                if (itemToReduce != null && reductionRepository.FindReduction(itemToReduce.Urls) == null)
                {
                    ItemBeingProcessed = itemToReduce;
                    key = Hasher.Hash(itemToReduce.Urls);
                    RRTracer.Trace("dequeued and processing {0} with key {1}.", itemToReduce.Urls, key);
                    var url = store.GetUrlByKey(key, itemToReduce.ResourceType);
                    if (url != null)
                    {
                        RRTracer.Trace("found url {0} in store for key {1}", url, key);
                        reductionRepository.AddReduction(key, url);
                    }
                    else
                    {
                        if (dictionaryOfFailure.ContainsKey(key) && dictionaryOfFailure[key] >= FailureThreshold)
                        {
                            RRTracer.Trace("{0} has exceeded its failure threshold and will not be processed.", itemToReduce.Urls);
                            return;
                        }
                        var reducer = RRContainer.Current.GetAllInstances<IReducer>().SingleOrDefault(x => x.SupportedResourceType == itemToReduce.ResourceType);
                        reducer.Process(key, itemToReduce.Urls);
                    }
                    RRTracer.Trace("dequeued and processed {0}.", itemToReduce.Urls);
                }
            }
            catch(Exception e)
            {
                var message = string.Format("There were errors reducing {0}", itemToReduce != null ? itemToReduce.Urls : "");
                var wrappedException =
                    new ApplicationException(message, e);
                RRTracer.Trace(message);
                RRTracer.Trace(e.ToString());
                if(dictionaryOfFailure.ContainsKey(key))
                    dictionaryOfFailure[key] += 1;
                else
                    dictionaryOfFailure.Add(key, 1);
                if (Registry.CaptureErrorAction != null)
                    Registry.CaptureErrorAction(wrappedException);
            }
            finally
            {
                ItemBeingProcessed = null;
            }
        }
예제 #54
0
 /// <summary>
 /// Called to process this item in its own particular way.
 /// queueItem notes should be filled in on failure.
 /// </summary>
 /// <param name="queueItem">queue item to process</param>
 /// <returns>true if successful, false if failed</returns>
 public abstract bool ProcessRequest(IQueueItem queueItem);
        public void Enqueue_EmptyCollection_NoItemIsEnqueued()
        {
            // Arrange
            var queue = new SystemInformationMessageQueue();
            var items = new IQueueItem<SystemInformation>[] { };

            // Act
            queue.Enqueue(items);

            // Assert
            Assert.AreEqual(0, queue.GetSize());
        }
예제 #56
0
 /// <summary>
 /// Remove a queue item from the local retry queues
 /// </summary>
 /// <param name="queueItem"></param>
 private void RemoveQueueItemFromRetryQueue(IQueueItem queueItem)
 {
     DateTime retryTime;
     int retries;
     retriesLeft.TryRemove(queueItem.Id.Value, out retries);
     nextRetryTime.TryRemove(queueItem.Id.Value, out retryTime);
     retryQueueItems.TryRemove(queueItem.Id.Value, out queueItem);
 }
예제 #57
0
 /// <summary>
 /// Get item from queue
 /// </summary>
 /// <param name="queueItem">Implementer of IQueueItem with required data for retrieving a queue item</param>
 /// <returns>Implementer of IQueueItem</returns>
 public virtual IQueueItem GetQueueItem(IQueueItem queueItem)
 {
     return queueProcessor.GetQueueItem(queueItem);
 }
예제 #58
0
        /// <summary>
        /// queue item retry re-scheduler
        /// fail if no retries set up or left
        /// </summary>
        /// <param name="exc">Exception that occurred to cause this to be re-scheduled</param>
        /// <param name="queueItem">Queue Item to re-schedule</param>
        public virtual void ScheduleRetryAndHandleFailure(IQueueItem queueItem, Exception exc)
        {
            if (RetryIntervalSettings != null)
            {
                if (RetryIntervalSettings.Interval.HasValue == false)
                {
                    RetryIntervalSettings.Interval = DEFAULT_INTERVAL;
                }

                int retries = -1;
                if (retriesLeft.TryGetValue(queueItem.Id.Value, out retries))
                {
                    if (retries > 0)
                    {
                        // subtract one and set value in retry dict
                        retries = retries - 1;

                        // odd case for particular exception, set as force process
                        if (retries == 0 && // last retry
                            exc != null &&
                            exc.GetType() == typeof (ValidationException))
                        {
                            ValidationException vex = exc as ValidationException;

                            // particular exception case
                            if (Errors.SRVEX30113.ToString() == vex.Code)
                            {
                                // set it to be force processed
                                queueItem.ForceProcess = true;
                            }
                        }
                    }
                    else
                    {
                        // out of retries, remove then fail it
                        RemoveQueueItemFromRetryQueue(queueItem);

                        if (exc != null)
                        {
                            queueItem.Notes = exc.Message;
                        }

                        queueManager.FailQueueItem(queueItem);
                        Log.LogError("{0} - Error occurred while processing invoice request for queue item {1}. {2}", null, null, TaskName, queueItem.Id, queueItem.Notes);
                        return;
                    }
                }
                else
                {
                    retries = RetryIntervalSettings.RetryCount;
                }
                
                Log.LogInfo("{0} - queue item with id {1} has {2} retries left. {3}", null, TaskName, queueItem.Id.Value, retries, exc != null ? Environment.NewLine + exc.Message + " " + exc.StackTrace : string.Empty);

                retriesLeft.AddOrUpdate(queueItem.Id.Value, retries, (key, value) => retries);
                DateTime newTime = DateTime.UtcNow.Add(RetryIntervalSettings.Interval.Value);
                nextRetryTime.AddOrUpdate(queueItem.Id.Value, newTime, (key, value) => newTime);
                retryQueueItems.AddOrUpdate(queueItem.Id.Value, queueItem, (key, value) => queueItem);
            }
            else
            {
                // no retry, so just fail right away
                if (exc != null)
                {
                    queueItem.Notes = exc.Message;
                }
                queueManager.FailQueueItem(queueItem);
                Log.LogError("{0} - Error occurred while processing invoice request for queue item {1}. {2}", null, null, TaskName, queueItem.Id, queueItem.Notes);
            }
        }
예제 #59
0
 public void Enqueue(IQueueItem item)
 {
     _queue.Enqueue(item);
 }
예제 #60
0
 /// <summary>
 /// Remove/Fail item from queue
 /// </summary>
 /// <param name="queueItem">Implementer of IQueueItem</param>
 public virtual void FailQueueItem(IQueueItem queueItem)
 {
     queueProcessor.FailQueueItem(queueItem);
 }