Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use isolated dispatch for control message to prevent attaching to outbox's transaction scope if transport supports transaction scopes #403

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Extensibility;
using Fakes;
using NServiceBus.Transport;
using NUnit.Framework;

[TestFixture]
Expand Down Expand Up @@ -135,6 +136,7 @@ public async Task Commit_should_send_control_message_and_store_outbox_data()
var controlMessage = dispatched.outgoingMessages.UnicastTransportOperations.Single();
Assert.Multiple(() =>
{
Assert.That(controlMessage.RequiredDispatchConsistency, Is.EqualTo(DispatchConsistency.Isolated));
Assert.That(controlMessage.Message.MessageId, Is.EqualTo(session.SessionId));
Assert.That(controlMessage.Message.Headers[Headers.ControlMessageHeader], Is.EqualTo(bool.TrueString));
Assert.That(controlMessage.Message.Body.IsEmpty, Is.True);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Extensibility;
using Fakes;
using NUnit.Framework;
using Transport;

[TestFixture]
public class TransactionalSessionTests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ async Task DispatchControlMessage(CancellationToken cancellationToken)
}
}
var message = new OutgoingMessage(SessionId, headers, ReadOnlyMemory<byte>.Empty);
var outgoingMessages = new TransportOperations(new TransportTransportOperation(message, new UnicastAddressTag(physicalQueueAddress)));
var operation = new TransportTransportOperation(
message,
new UnicastAddressTag(physicalQueueAddress),
null,
DispatchConsistency.Isolated // Avoids promoting to distributed tx by not combining transport and persistence when both share same technology
);
var outgoingMessages = new TransportOperations(operation);
await dispatcher.Dispatch(outgoingMessages, new TransportTransaction(), cancellationToken).ConfigureAwait(false);
}

Expand Down