public override async Task <Message> ReceiveAsync(TimeoutHelper timeoutHelper) { Logging.Enter(this, timeoutHelper, timeoutHelper.GetRemainingTime(), nameof(ReceiveAsync)); Message message = await _amqpUnit.ReceiveMessageAsync(timeoutHelper.GetRemainingTime()).ConfigureAwait(false); Logging.Exit(this, timeoutHelper, timeoutHelper.GetRemainingTime(), nameof(ReceiveAsync)); return(message); }
public override async Task <Message> ReceiveAsync(TimeoutHelper timeoutHelper) { if (Logging.IsEnabled) { Logging.Enter(this, timeoutHelper, timeoutHelper.RemainingTime(), $"{nameof(ReceiveAsync)}"); } Message message = await _amqpUnit.ReceiveMessageAsync(timeoutHelper.RemainingTime()).ConfigureAwait(false); if (Logging.IsEnabled) { Logging.Exit(this, timeoutHelper, timeoutHelper.RemainingTime(), $"{nameof(ReceiveAsync)}"); } return(message); }
public override async Task <Message> ReceiveAsync(TimeSpan timeout, CancellationToken cancellationToken) { if (Logging.IsEnabled) { Logging.Enter(this, timeout, cancellationToken, $"{nameof(ReceiveAsync)}"); } Message message = null; while (true) { cancellationToken.ThrowIfCancellationRequested(); try { message = await _amqpUnit.ReceiveMessageAsync(timeout).ConfigureAwait(false); if (message != null) { break; } } catch (Exception exception) when(!exception.IsFatal() && !(exception is OperationCanceledException)) { throw AmqpClientHelper.ToIotHubClientContract(exception); } } if (Logging.IsEnabled) { Logging.Exit(this, timeout, cancellationToken, $"{nameof(ReceiveAsync)}"); } return(message); }
public override async Task <Message> ReceiveAsync(TimeSpan timeout, CancellationToken cancellationToken) { if (Logging.IsEnabled) { Logging.Enter(this, timeout, cancellationToken, $"{nameof(ReceiveAsync)}"); } Message message = null; while (true) { cancellationToken.ThrowIfCancellationRequested(); message = await _amqpUnit.ReceiveMessageAsync(timeout).ConfigureAwait(false); if (message != null) { break; } } if (Logging.IsEnabled) { Logging.Exit(this, timeout, cancellationToken, $"{nameof(ReceiveAsync)}"); } return(message); }
public override async Task <Message> ReceiveAsync(TimeoutHelper timeoutHelper) { if (Logging.IsEnabled) { Logging.Enter(this, timeoutHelper, timeoutHelper.GetRemainingTime(), nameof(ReceiveAsync)); } using var cts = new CancellationTokenSource(timeoutHelper.GetRemainingTime()); Message message = await _amqpUnit.ReceiveMessageAsync(cts.Token).ConfigureAwait(false); if (Logging.IsEnabled) { Logging.Exit(this, timeoutHelper, timeoutHelper.GetRemainingTime(), nameof(ReceiveAsync)); } return(message); }