Пример #1
0
        public AmqpSession(AmqpConnection connection, NmsSessionInfo sessionInfo)
        {
            Connection  = connection;
            SessionInfo = sessionInfo;

            if (sessionInfo.IsTransacted)
            {
                TransactionContext = new AmqpTransactionContext(this);
            }
        }
Пример #2
0
        public void Acknowledge(InboundMessageDispatch envelope, AckType ackType)
        {
            if (envelope.Message.Facade is AmqpNmsMessageFacade facade)
            {
                global::Amqp.Message message = facade.Message;
                switch (ackType)
                {
                case AckType.DELIVERED:
                    envelope.IsDelivered = true;
                    break;

                case AckType.ACCEPTED:
                    AmqpTransactionContext transactionalState = session.TransactionContext;
                    if (transactionalState != null)
                    {
                        receiverLink.Complete(message, transactionalState.GetTxnAcceptState());
                        transactionalState.RegisterTxConsumer(this);
                    }
                    else
                    {
                        receiverLink.Accept(message);
                    }
                    RemoveMessage(envelope);
                    break;

                case AckType.RELEASED:
                    receiverLink.Release(message);
                    RemoveMessage(envelope);
                    break;

                case AckType.MODIFIED_FAILED_UNDELIVERABLE:
                    receiverLink.Modify(message, true, true);
                    RemoveMessage(envelope);
                    break;

                default:
                    Tracer.Error($"Unsupported Ack Type for message: {envelope.Message}");
                    throw new ArgumentException($"Unsupported Ack Type for message: {envelope.Message}");
                }
            }
            else
            {
                Tracer.ErrorFormat($"Received Ack for unknown message: {envelope}");
            }
        }