Skip to content

Add ConversationId propagation support in Mocha#9302

Merged
PascalSenn merged 2 commits intomainfrom
pse/add-conversation-id-propagation
Mar 5, 2026
Merged

Add ConversationId propagation support in Mocha#9302
PascalSenn merged 2 commits intomainfrom
pse/add-conversation-id-propagation

Conversation

@PascalSenn
Copy link
Copy Markdown
Member

@PascalSenn PascalSenn commented Mar 4, 2026

Introduce a ConsumeContextAccessor scoped service that captures the ambient consume context during message handling. DefaultMessageBus uses this accessor to automatically propagate ConversationId and CausationId when publishing or sending messages from within a consumer, removing the need for manual correlation ID forwarding.

  Introduce a ConsumeContextAccessor scoped service that captures the ambient
  consume context during message handling. DefaultMessageBus uses this accessor
  to automatically propagate ConversationId and CausationId when publishing or
  sending messages from within a consumer, removing the need for manual
  correlation ID forwarding.
Copilot AI review requested due to automatic review settings March 4, 2026 22:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an ambient consume-context accessor to enable automatic propagation of message conversation/causation identifiers when publishing/sending from within a consumer, and adds in-memory transport tests to validate correlation behavior.

Changes:

  • Add a scoped ConsumeContextAccessor that captures the current IConsumeContext during receive execution.
  • Update DefaultMessageBus to use the accessor to propagate ConversationId/CausationId for outgoing operations.
  • Add new in-memory transport tests validating ID generation and multi-hop propagation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Mocha/test/Mocha.Transport.InMemory.Tests/Behaviors/CorrelationTests.cs Adds coverage for correlation/conversation/causation behaviors including chained publish.
src/Mocha/src/Mocha/Middlewares/DefaultMessageBus.cs Injects accessor and propagates ambient IDs into pooled DispatchContext before initialization/dispatch.
src/Mocha/src/Mocha/Endpoints/ReceiveEndpoint.cs Sets the ambient accessor’s Context before running the receive pipeline.
src/Mocha/src/Mocha/Context/ConsumeContextAccessor.cs Introduces new scoped accessor service for the current consume context.
src/Mocha/src/Mocha/Builder/MessageBusOptions.cs Registers the accessor as a scoped dependency of the bus.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Mocha/src/Mocha/Endpoints/ReceiveEndpoint.cs
Comment thread src/Mocha/src/Mocha/Middlewares/DefaultMessageBus.cs
@PascalSenn PascalSenn merged commit 7eaed1b into main Mar 5, 2026
123 checks passed
@PascalSenn PascalSenn deleted the pse/add-conversation-id-propagation branch March 5, 2026 11:15
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (9e2bfc3) to head (d6c7fbc).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff      @@
##   main   #9302   +/-   ##
============================
============================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants