Skip to content

Fixed Batch Consumer Middleware Pipeline - #9962

Merged
PascalSenn merged 4 commits into
mainfrom
pse/fix-batch-consumer-pipeline
Jun 22, 2026
Merged

PascalSenn merged 4 commits into
mainfrom
pse/fix-batch-consumer-pipeline

Conversation

@PascalSenn

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings June 21, 2026 23:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes batch consumer processing so batch handlers execute through the normal consumer middleware pipeline (instead of bypassing it), and extends the runtime + tests to properly support batch-specific context/telemetry and correlation propagation.

Changes:

  • Run batch handler execution through the compiled consumer pipeline using a dedicated BatchConsumeContext and expose the compiled pipeline to derived consumers.
  • Add batch-aware causation propagation (BatchId) when publishing from within a batch handler, plus inbox/outbox handling for batch deliveries.
  • Add integration/telemetry tests to validate batch context behavior, inbox/outbox behavior, and OpenTelemetry linking for batch consumption.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Mocha/test/Mocha.Tests/Telemetry/OpenTelemetryTests.cs Adds batch telemetry test and transport configuration hook for in-memory endpoint setup.
src/Mocha/test/Mocha.Tests/Outbox/OutboxIntegrationTests.cs Adds test ensuring batch-id is used as causation when publishing from a batch handler; adds transport configuration hook.
src/Mocha/test/Mocha.Tests/Inbox/InboxIntegrationTests.cs Adds test validating inbox records each batch entry; adds transport configuration hook.
src/Mocha/test/Mocha.Tests/Consumers/Batching/BatchConsumerIntegrationTests.cs Adds integration test asserting middleware pipeline sees a proper batch consume context and ambient accessor context is batch-aware.
src/Mocha/src/Mocha/Middlewares/DefaultMessageBus.cs Uses BatchId as causation id when publishing/sending from within a batch consume context.
src/Mocha/src/Mocha/Instrumentation/ActivityMessagingDiagnosticListener.cs Adds activity-context linking for batch consumes and batch tags; stores receive activity context in features for later linking.
src/Mocha/src/Mocha/Consumers/Implementations/BatchConsumer.cs Routes batch processing through the consumer middleware pipeline using a new BatchConsumeContext and ambient accessor wiring.
src/Mocha/src/Mocha/Consumers/Consumer.cs Exposes compiled consumer pipeline to derived types and allows overriding ProcessAsync.
src/Mocha/src/Mocha/Consumers/Batching/BatchConsumeContext.cs Introduces batch consume context implementation used to execute batch processing through the pipeline.
src/Mocha/src/Mocha/Abstractions/IMessageBatch.cs Adds non-generic IMessageBatch base interface to enable non-generic batch consume contexts.
src/Mocha/src/Mocha/Abstractions/Context/IBatchConsumeContext~1.cs Adds typed batch consume context abstraction.
src/Mocha/src/Mocha/Abstractions/Context/IBatchConsumeContext.cs Adds non-generic batch consume context abstraction.
src/Mocha/src/Mocha.Inbox/ConsumeInboxMiddleware.cs Adds batch-aware inbox claiming/existence logic per batch entry.

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

Comment thread src/Mocha/src/Mocha/Consumers/Batching/BatchConsumeContext.cs Outdated
@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall coverage in the pse/fix-batch-consum... branch remains at 49%, unchanged from the main branch.

Show a code coverage summary of the most impacted files.
File main 4df88cd pse/fix-batch-consum... 81fff5d +/-
/home/runner/wo...tDiagnostics.cs 88% 73% -15%
/home/runner/wo...oxMiddleware.cs 72% 58% -14%
/home/runner/wo...entsListener.cs 66% 62% -4%
/home/runner/wo...tocolHandler.cs 84% 83% -1%
/home/runner/wo...boxProcessor.cs 72% 74% +2%
/home/runner/wo...ueryExecutor.cs 65% 67% +2%
/home/runner/wo...atchConsumer.cs 73% 77% +4%
/home/runner/wo...gerMessage.g.cs 15% 19% +4%
/home/runner/wo...umeContext~1.cs 47% 55% +8%
/home/runner/wo...nsumeContext.cs 0% 83% +83%

Code Coverage is in Public Preview. Learn more and provide us with your feedback.

PascalSenn and others added 2 commits June 22, 2026 01:55
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@PascalSenn
PascalSenn merged commit 11daf49 into main Jun 22, 2026
142 checks passed
@PascalSenn
PascalSenn deleted the pse/fix-batch-consumer-pipeline branch June 22, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants