private void HandleErrorInSubscriptionHandler(
     BasicDeliverEventArgs basicDeliverEventArgs,
     SubscriptionInfo subscriptionInfo,
     Exception exception)
 {
     logger.ErrorWrite(BuildErrorMessage(basicDeliverEventArgs, exception));
     consumerErrorStrategy.HandleConsumerError(basicDeliverEventArgs, exception);
     DoAck(basicDeliverEventArgs, subscriptionInfo);
 }
Ejemplo n.º 2
0
        private void DoAck(BasicDeliverEventArgs basicDeliverEventArgs, SubscriptionInfo subscriptionInfo)
        {
            const string failedToAckMessage = "Basic ack failed because chanel was closed with message {0}." +
                                              " Message remains on RabbitMQ and will be retried.";

            try
            {
                subscriptionInfo.Consumer.Model.BasicAck(basicDeliverEventArgs.DeliveryTag, false);
            }
            catch (AlreadyClosedException alreadyClosedException)
            {
                logger.InfoWrite(failedToAckMessage, alreadyClosedException.Message);
            }
            catch (IOException ioException)
            {
                logger.InfoWrite(failedToAckMessage, ioException.Message);
            }
        }
Ejemplo n.º 3
0
        private void DoAck(BasicDeliverEventArgs basicDeliverEventArgs, SubscriptionInfo subscriptionInfo, Action<IModel, ulong> ackStrategy)
        {
            const string failedToAckMessage = "Basic ack failed because channel was closed with message {0}." +
                                              " Message remains on RabbitMQ and will be retried.";

            try
            {
                ackStrategy(subscriptionInfo.Consumer.Model, basicDeliverEventArgs.DeliveryTag);

                if (subscriptionInfo.ModelIsSingleUse)
                {
                    subscriptionInfo.Consumer.CloseModel();
                    subscriptionInfo.SubscriptionAction.ClearAction();
                }
            }
            catch (AlreadyClosedException alreadyClosedException)
            {
                logger.InfoWrite(failedToAckMessage, alreadyClosedException.Message);
            }
            catch (IOException ioException)
            {
                logger.InfoWrite(failedToAckMessage, ioException.Message);
            }
            finally
            {
                if (SynchronisationAction != null)
                {
                    SynchronisationAction();
                }
            }
        }