public async Task ExecuteAsync(T message, Func <T, CancellationToken, Task> next, CancellationToken cancellationToken) { async Task NextAction(T batch, CancellationToken ct) { await _nextBehavior.ExecuteAsync(batch, next, ct); } await _behavior.ExecuteAsync(message, NextAction, cancellationToken); }
public async Task PublishAsync(IPublisherMessageBatching batching, CancellationToken cancellationToken = default) { if (batching is null) { throw new ArgumentNullException(nameof(batching)); } if (_disposed) { throw new ObjectDisposedException(nameof(Publisher)); } try { await _behavior.ExecuteAsync(batching, null, cancellationToken); OnNext(batching); } catch (PublishingNotConfirmedException ex) { OnError(ex); } catch (PublishingException ex) { OnError(ex); if (batching.Count > ex.Batching.Count) { OnNext(new PublisherMessageBatching(this, batching.Except(ex.Batching))); } } catch (EasyRabbitMqClientException ex) { OnError(new PublishingException(batching, ex.Message, ex)); } catch (Exception ex) { OnError(new PublishingException(batching, ex)); } }