Exemplo n.º 1
0
        public async Task <Message> ReceiveMessageAsync(TimeSpan timeout)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, timeout, $"{nameof(ReceiveMessageAsync)}");
            }

            try
            {
                await EnsureReceivingLinkIsOpenedAsync(timeout).ConfigureAwait(false);

                Debug.Assert(_messageSendingLink != null);

                return(await _messageReceivingLink.ReceiveAmqpMessageAsync(timeout).ConfigureAwait(false));
            }
            catch (Exception exception) when(!exception.IsFatal() && !(exception is OperationCanceledException))
            {
                throw AmqpIoTExceptionAdapter.ConvertToIoTHubException(exception);
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, timeout, $"{nameof(ReceiveMessageAsync)}");
                }
            }
        }
Exemplo n.º 2
0
        public async Task <Message> ReceiveMessageAsync(TimeSpan timeout)
        {
            if (Logging.IsEnabled)
            {
                Logging.Enter(this, timeout, $"{nameof(ReceiveMessageAsync)}");
            }
            await EnsureMessageReceivingLinkAsync(timeout).ConfigureAwait(false);

            try
            {
                Debug.Assert(_messageSendingLink != null);
                return(await _messageReceivingLink.ReceiveAmqpMessageAsync(timeout).ConfigureAwait(false));
            }
            finally
            {
                if (Logging.IsEnabled)
                {
                    Logging.Exit(this, timeout, $"{nameof(ReceiveMessageAsync)}");
                }
            }
        }
Exemplo n.º 3
0
        public async Task <Message> ReceiveMessageAsync(TimeSpan timeout)
        {
            if (_isDeviceReceiveMessageCallbackSet)
            {
                Logging.Error(this, "Callback handler set for receiving c2d messages, ReceiveAsync() will now always return null", nameof(ReceiveMessageAsync));
                return(null);
            }

            Logging.Enter(this, timeout, nameof(ReceiveMessageAsync));

            await EnsureMessageReceivingLinkIsOpenAsync(timeout).ConfigureAwait(false);

            try
            {
                Debug.Assert(_messageSendingLink != null);
                return(await _messageReceivingLink.ReceiveAmqpMessageAsync(timeout).ConfigureAwait(false));
            }
            finally
            {
                Logging.Exit(this, timeout, nameof(ReceiveMessageAsync));
            }
        }