/// <inheritdoc cref="IProducerBehavior.HandleAsync" /> public async Task HandleAsync(ProducerPipelineContext context, ProducerBehaviorHandler next) { Check.NotNull(context, nameof(context)); Check.NotNull(next, nameof(next)); MessageIdProvider.EnsureMessageIdIsInitialized(context.Envelope.Headers); await next(context).ConfigureAwait(false); }
public void EnsureMessageIdIsInitialized_NoHeaderSet_HeaderInitialized() { var headers = new MessageHeaderCollection(); MessageIdProvider.EnsureMessageIdIsInitialized(headers); headers.Should().HaveCount(1); headers.First().Name.Should().Be("x-message-id"); headers.First().Value.Should().NotBeNullOrWhiteSpace(); }
/// <inheritdoc cref="IProducerBehavior.HandleAsync" /> public async Task HandleAsync(ProducerPipelineContext context, ProducerBehaviorHandler next) { Check.NotNull(context, nameof(context)); Check.NotNull(next, nameof(next)); // TODO: Could avoid? Or make it optional (for interop with legacy versions)? MessageIdProvider.EnsureMessageIdIsInitialized(context.Envelope.Headers); await next(context).ConfigureAwait(false); }
public void EnsureMessageIdIsInitialized_IdHeaderAlreadySet_HeaderPreserved() { var headers = new MessageHeaderCollection { { "x-message-id", "12345" } }; MessageIdProvider.EnsureMessageIdIsInitialized(headers); headers.Should().BeEquivalentTo(new MessageHeader("x-message-id", "12345")); }