コード例 #1
0
        private void GenericSubscriptionQueue_MessageReceived
            (RabbitMQ.Client.IBasicConsumer sender, RabbitMQ.Client.Events.BasicDeliverEventArgs args)
        {
            RabbitMQ.Client.Events.EventingBasicConsumer consumer = (RabbitMQ.Client.Events.EventingBasicConsumer)sender;

            try
            {
                // don't reprocess items that have been processed
                if (_genericSubscriptionQueue.GetLastProcessedUndelivered() != args.DeliveryTag)
                {
                    string rawOrder = Encoding.ASCII.GetString(args.Body);

                    ProcessOrder(rawOrder);
                }

                _genericSubscriptionQueue.Ack(consumer, args.DeliveryTag);
            }
            catch (QueueDataError <string> serializationEx)
            {
                _log.WriteErrorLog("Serializing problem with order update.", serializationEx);
            }
            catch (Exception ex)
            {
                _log.WriteErrorLog("Unhandled error processing order update.", ex);
            }
        }
コード例 #2
0
        private void GenericSubscriptionQueue_MessageReceived
            (RabbitMQ.Client.IBasicConsumer sender, RabbitMQ.Client.Events.BasicDeliverEventArgs args)
        {
            RabbitMQ.Client.Events.EventingBasicConsumer consumer = (RabbitMQ.Client.Events.EventingBasicConsumer)sender;

            try {
                // don't reprocess items that have been processed
                if (genericSubscriptionQueue.GetLastProcessedUndelivered() != args.DeliveryTag)
                {
                    BaseNotification notification = NotificationExtension.Deserialize(Encoding.ASCII.GetString(args.Body));

                    eventLogRepository.WriteInformationLog("Processing notification type: {NotificationType}. Data: {QueueMessage}".Inject(new { QueueMessage = notification.ToJson(), NotificationType = notification.NotificationType.ToString() }));

                    var handler = notificationHandlerFactory(notification.NotificationType); // autofac will get the right handler
                    handler.ProcessNotification(notification);

                    // Always clear the context at the end of a transaction
                    _uow.ClearContext();
                }

                genericSubscriptionQueue.Ack(consumer, args.DeliveryTag);
            } catch (QueueDataError <string> serializationEx)  {
                eventLogRepository.WriteErrorLog("Serializing problem with notification.", serializationEx);
            } catch (QueueDataError <BaseNotification> notificationEx) {
                eventLogRepository.WriteErrorLog("Error processing notification.", notificationEx);

                PublishToQueue(notificationEx.ProcessingObject, Configuration.RabbitMQNotificationErrorQueue);
            } catch (Exception ex) {
                eventLogRepository.WriteErrorLog("Unhandled error processing notification.", ex);
            }
        }
コード例 #3
0
        private void GenericSubscriptionQueue_MessageReceived
            (RabbitMQ.Client.IBasicConsumer sender, RabbitMQ.Client.Events.BasicDeliverEventArgs args)
        {
            RabbitMQ.Client.Events.EventingBasicConsumer consumer = (RabbitMQ.Client.Events.EventingBasicConsumer)sender;

            try
            {
                // don't reprocess items that have been processed
                if (_genericSubscriptionQueue.GetLastProcessedUndelivered() != args.DeliveryTag)
                {
                    string msg = Encoding.ASCII.GetString(args.Body);

                    PushMessage pushmessage = JsonConvert.DeserializeObject <PushMessage>(msg);

                    _eventLogRepository.WriteInformationLog
                        ("Processing push message from queue. Notification: {QueueMessage}".InjectSingleValue
                            ("QueueMessage", msg));

                    ProcessIncomingPushMessage(pushmessage);
                }

                _genericSubscriptionQueue.Ack(consumer, args.DeliveryTag);
            }
            catch (QueueDataError <string> serializationEx)
            {
                _eventLogRepository.WriteErrorLog("Serializing problem with push message.", serializationEx);
            }
            catch (QueueDataError <BaseNotification> notificationEx)
            {
                _eventLogRepository.WriteErrorLog("Error processing push message.", notificationEx);
            }
            catch (Exception ex)
            {
                _eventLogRepository.WriteErrorLog("Unhandled error processing push message.", ex);
            }
        }