Skip to content

Commit

Permalink
Added envelop mapping for CorrelationId, added checks to NSB interop …
Browse files Browse the repository at this point in the history
…unit test
  • Loading branch information
Michael Paperin authored and jeremydmiller committed Oct 10, 2023
1 parent 776d5c9 commit 2b18777
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,21 @@ public async Task nservicebus_sends_message_to_wolverine()
ResponseHandler.Received.Clear();

var id = Guid.NewGuid();

var messageId = Guid.NewGuid().ToString();

var session = await theFixture.Wolverine.ExecuteAndWaitAsync(async () =>
{
var options = new PublishOptions();
options.SetMessageId(messageId);
var sender = theFixture.NServiceBus.Services.GetRequiredService<IMessageSession>();
await sender.Publish(new ResponseMessage { Id = id });
await sender.Publish(new ResponseMessage { Id = id }, options);
}, 60000);

var envelope = ResponseHandler.Received.FirstOrDefault();
envelope.Message.ShouldBeOfType<ResponseMessage>().Id.ShouldBe(id);
envelope.ShouldNotBeNull();

envelope.CorrelationId.ShouldNotBeNull();
envelope.CorrelationId.ShouldBe(messageId);
envelope.Id.ShouldNotBe(Guid.Empty);
envelope.ConversationId.ShouldNotBe(Guid.Empty);
}
Expand All @@ -46,19 +48,23 @@ public async Task nservicebus_sends_interface_to_wolverine_who_only_understands_
ResponseHandler.Received.Clear();

var id = Guid.NewGuid();

var messageId = Guid.NewGuid().ToString();

var session = await theFixture.Wolverine.ExecuteAndWaitAsync(async () =>
{
var options = new SendOptions();
options.SetMessageId(messageId);
options.SetDestination("wolverine");
var sender = theFixture.NServiceBus.Services.GetRequiredService<IMessageSession>();
await sender.Send<IInterfaceMessage>("wolverine", x => x.Id = id );
await sender.Send<IInterfaceMessage>(x => x.Id = id, options);
}, 60000);

var envelope = ResponseHandler.Received.FirstOrDefault();
envelope.Message.ShouldBeOfType<ConcreteMessage>().Id.ShouldBe(id);
envelope.ShouldNotBeNull();

envelope.CorrelationId.ShouldNotBeNull();
envelope.CorrelationId.ShouldBe(messageId);
envelope.Id.ShouldNotBe(Guid.Empty);
envelope.ConversationId.ShouldNotBe(Guid.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public void UseNServiceBusInterop()
{
m.MapPropertyToHeader(x => x.ConversationId, "NServiceBus.ConversationId");
m.MapPropertyToHeader(x => x.SentAt, "NServiceBus.TimeSent");

m.MapPropertyToHeader(x => x.CorrelationId!, "NServiceBus.CorrelationId");

var replyAddress = new Lazy<string>(() =>
{
var replyEndpoint = (RabbitMqEndpoint)_parent.ReplyEndpoint()!;
Expand Down

0 comments on commit 2b18777

Please sign in to comment.