Skip to content

Remove forced DispatchConsistency.Isolated for outbox operations#7604

Open
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-outbox-batching-issue
Open

Remove forced DispatchConsistency.Isolated for outbox operations#7604
Copilot wants to merge 3 commits intomasterfrom
copilot/fix-outbox-batching-issue

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Outbox was forcing DispatchConsistency.Isolated on all operations, preventing transports from batching messages. This was redundant - the outbox already enforces TransportTransactionMode.ReceiveOnly, which by definition prevents enlistment in receive transactions.

Changes

  • Removed ForceBatchDispatchToBeIsolatedBehavior - Deleted behavior class and its pipeline registration
  • Updated TransportReceiveToPhysicalMessageConnector - Changed outbox operation dispatch consistency from Isolated to Default
  • Updated Outbox.cs comments - Clarified that ReceiveOnly mode already provides isolation guarantees

Impact

Transports supporting batching (Azure Service Bus, Amazon SQS) can now batch outbox operations, reducing latency and message operation costs.

// Before: Each operation dispatched individually
operation.RequiredDispatchConsistency = DispatchConsistency.Isolated;

// After: Transport decides batching strategy
operation.RequiredDispatchConsistency = DispatchConsistency.Default;

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • f.feedz.io
    • Triggering command: /usr/bin/dotnet dotnet build src/NServiceBus.Core/NServiceBus.Core.csproj --no-restore (dns block)
    • Triggering command: /usr/bin/dotnet dotnet build --no-restore -c Release (dns block)
    • Triggering command: /usr/bin/dotnet dotnet restore src/NServiceBus.Core.Tests/NServiceBus.Core.Tests.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Outbox prevents transports from batching outgoing messages</issue_title>
<issue_description>When outbox is enabled, all outgoing messages are forced to use DispatchConsistency.Isolated. This causes transports that support batching, at the time of writing, Azure Service Bus and Amazon SQS, not to use batching but rather send messages one by one. This leads to increased latency and higher costs since the number of message operations increases.

This behavior should not be needed since the outbox will force the transport transaction mode to be ReceiveOnly, which by definition prevents outgoing messages from being enlisted in the receive transaction.

Expected behavior

Dispatch consistency NOT changed on outgoing messages when the outbox is enabled.

Actual behavior

Dispatch consistency changed to DispatchConsistency.Isolated on outgoing messages when the outbox is enabled.

Versions

All supported versions.

Steps to reproduce

Enable the outbox, send more than one message using either Azure ServiceBus or Amazon SQS. Notice that batching is not used.

Relevant log output

Additional Information

Workarounds

Possible solutions

Additional information

</issue_description>

<agent_instructions>fix this bug and add proper tests and acceptance test following the conventions already use in the code. Ping @andreasohlund and me as a reviewer when done.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@andreasohlund We have reviewed this bug and added it to our bug fix queue. However, there is no ETA for when we will get to this bug as it may be prioritized behind other, more urgent, bugs. We will update this issue when it has a team assigned and work begins. @andreasohlund @bbrandt it has always existed

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@danielmarbach
Copy link
Contributor

@copilot try again

Copilot AI and others added 2 commits February 1, 2026 13:09
This change removes the ForceBatchDispatchToBeIsolatedBehavior and changes the dispatch consistency from Isolated to Default when dispatching outbox operations. This allows transports like Azure Service Bus and Amazon SQS to use batching for better performance and lower costs.

The behavior was originally added to prevent operations from being enlisted in the receive transaction, but this is already guaranteed by the outbox forcing TransportTransactionMode.ReceiveOnly, which by definition prevents outgoing messages from being enlisted in the receive transaction.

Co-authored-by: danielmarbach <174258+danielmarbach@users.noreply.github.com>
Co-authored-by: danielmarbach <174258+danielmarbach@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix outbox preventing transports from batching messages Remove forced DispatchConsistency.Isolated for outbox operations Feb 1, 2026
@danielmarbach danielmarbach marked this pull request as ready for review February 1, 2026 18:58
Copy link
Member

@andreasohlund andreasohlund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we deal with users that was "relying" on this behavior like. https://discuss.particular.net/t/azure-service-bus-large-number-of-commands-outbox/4483

Do we need to make this opt-in for sometime?

@bbrandt
Copy link

bbrandt commented Feb 2, 2026

How do we deal with users that was "relying" on this behavior like. https://discuss.particular.net/t/azure-service-bus-large-number-of-commands-outbox/4483

Do we need to make this opt-in for sometime?

Maybe we'd want to allow tuning of the message batch size when using outbox? When sending messages with outbox we can prioritize performance since we are not batching for reasons of transactional consistency, maybe?

@andreasohlund andreasohlund removed their assignment Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Outbox prevents transports from batching outgoing messages

4 participants

Comments