Exemple #1
0
        public override async Task SendEventAsync(Message message, CancellationToken cancellationToken)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, message, cancellationToken, $"{nameof(SendEventAsync)}");
            }

            try
            {
                cancellationToken.ThrowIfCancellationRequested();

                Outcome outcome = await _amqpUnit.SendEventAsync(message.ToAmqpMessage(), _operationTimeout).ConfigureAwait(false);

                if (outcome != null)
                {
                    if (outcome.DescriptorCode != Accepted.Code)
                    {
                        throw AmqpErrorMapper.GetExceptionFromOutcome(outcome);
                    }
                }
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, message, cancellationToken, $"{nameof(SendEventAsync)}");
                }
            }
        }
        public override async Task SendEventAsync(Message message, CancellationToken cancellationToken)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, message, cancellationToken, $"{nameof(SendEventAsync)}");
            }

            try
            {
                cancellationToken.ThrowIfCancellationRequested();
                AmqpIoTOutcome amqpIoTOutcome = await _amqpUnit.SendEventAsync(message, _operationTimeout).ConfigureAwait(false);

                if (amqpIoTOutcome != null)
                {
                    amqpIoTOutcome.ThrowIfNotAccepted();
                }
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, message, cancellationToken, $"{nameof(SendEventAsync)}");
                }
            }
        }
Exemple #3
0
        public override async Task SendEventAsync(Message message, CancellationToken cancellationToken)
        {
            Logging.Enter(this, message, cancellationToken, nameof(SendEventAsync));

            try
            {
                cancellationToken.ThrowIfCancellationRequested();
                AmqpIotOutcome amqpIotOutcome = await _amqpUnit.SendEventAsync(message, _operationTimeout).ConfigureAwait(false);

                amqpIotOutcome?.ThrowIfNotAccepted();
            }
            finally
            {
                Logging.Exit(this, message, cancellationToken, nameof(SendEventAsync));
            }
        }
        public override async Task SendEventAsync(Message message, CancellationToken cancellationToken)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, message, cancellationToken, nameof(SendEventAsync));
            }

            try
            {
                cancellationToken.ThrowIfCancellationRequested();

                using var ctb = new CancellationTokenBundle(_operationTimeout, cancellationToken);
                AmqpIotOutcome amqpIotOutcome = await _amqpUnit.SendEventAsync(message, ctb.Token).ConfigureAwait(false);

                amqpIotOutcome?.ThrowIfNotAccepted();
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, message, cancellationToken, nameof(SendEventAsync));
                }
            }
        }