Skip to content

feat(mediator): prepare outbound Rebus composition - #828

Merged
AndreaCuneo merged 13 commits into
masterfrom
copilot/azure-function-task
Aug 3, 2026
Merged

feat(mediator): prepare outbound Rebus composition#828
AndreaCuneo merged 13 commits into
masterfrom
copilot/azure-function-task

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Azure Functions hosts require outbound-only Rebus configuration without receivers, workers, or local request/reply semantics.

  • Composition
    • Add reusable ApplicationComposition.RegisterOutboundRebus(...).
    • Separate transport and generated owner-routing configuration.
  • Message dispatch
    • Replace SendLocal with routable Send for owned workflow messages.
  • Documentation
    • Document one-way hosting constraints, managed identity usage, and unsupported local receive behavior.
    • Update Azure Functions task tracking.
ApplicationComposition.RegisterOutboundRebus(
    container,
    transport => transport.UseAzureServiceBusAsOneWayClient(
        connectionString,
        new DefaultAzureCredential()),
    ArkGeneratedEndpoints.ConfigureArkRebusRouting<ApplicationAssemblyMarker>);

Copilot AI and others added 2 commits August 3, 2026 08:34
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI and others added 2 commits August 3, 2026 09:03
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI and others added 2 commits August 3, 2026 10:19
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI requested a review from AndreaCuneo August 3, 2026 10:26
@AndreaCuneo
AndreaCuneo marked this pull request as ready for review August 3, 2026 10:30
@AndreaCuneo
AndreaCuneo requested a review from a team as a code owner August 3, 2026 10:30
Copilot AI review requested due to automatic review settings August 3, 2026 10:30

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

Prepares the mediator/Rebus setup for outbound-only hosts (notably Azure Functions) by introducing a reusable outbound Rebus registration path, updating sample compositions to split “API host” vs “processor” responsibilities, and documenting one-way hosting constraints.

Changes:

  • Add ApplicationComposition.RegisterOutboundRebus(...) to register Rebus as a one-way outbound client with generated routing.
  • Update the sample to use outbound-only Rebus in the web host and introduce a separate Ark.MediatorFramework.Sample.RebusProcessor executable for receiving/processing.
  • Add an Azure Functions isolated-worker sample host + update docs/task tracking for one-way Rebus hosting.

Reviewed changes

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

Show a summary per file
File Description
src/mediator-framework/Ark.Tools.MediatorFramework.AzureFunctions/ArkAzureFunctionsServiceCollectionExtensions.cs Registers IHttpContextAccessor + a ClaimsPrincipal context provider for Functions DI/container integration.
samples/Ark.MediatorFramework.Sample/test/Ark.MediatorFramework.Sample.Tests/packages.lock.json Updates lockfile to reflect new project reference/dependency graph.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.WebInterface/SampleComposition.cs Switches web host Rebus setup to outbound-only registration and wires routing via the new endpoints facade.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.WebInterface/SampleBusHostedService.cs Starts both the outbound web-host bus and a separate processor container/bus.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.WebInterface/packages.lock.json Updates lockfile for added processor project reference.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.WebInterface/Ark.MediatorFramework.Sample.WebInterface.csproj Removes direct Rebus mediator package ref and adds project reference to the new processor project.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.RebusProcessor/SampleRebusEndpoints.cs New: exposes generated handler registration + routing configuration to hosts.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.RebusProcessor/RebusProcessorComposition.cs New: builds the “full processor” container (receivers/handlers/outbox processor).
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.RebusProcessor/Program.cs New: runnable processor entrypoint for the sample.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.RebusProcessor/packages.lock.json New: lockfile for processor project dependencies.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.RebusProcessor/Ark.MediatorFramework.Sample.RebusProcessor.csproj New: processor project definition + analyzer wiring.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.AzureFunctions/Program.cs New: Functions isolated-worker sample host that composes the app container and generated HTTP triggers.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.AzureFunctions/packages.lock.json New: lockfile for Functions host dependencies.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.AzureFunctions/local.settings.json.example New: example local settings for Functions Core Tools.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.AzureFunctions/host.json New: configures empty route prefix so generated routes stay /api/v1/....
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.AzureFunctions/Ark.MediatorFramework.Sample.AzureFunctions.csproj New: Functions host project definition.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.Application/GreetingHandlers.cs Replaces SendLocal with routable Send for owned workflow messages.
samples/Ark.MediatorFramework.Sample/src/Ark.MediatorFramework.Sample.Application/ApplicationComposition.cs Adds RegisterOutboundRebus(...) and allows optional external IGreetingStore injection.
samples/Ark.MediatorFramework.Sample/README.md Documents the new Azure Functions host sample and local run instructions.
samples/Ark.MediatorFramework.Sample/Directory.Packages.props Adds Functions-related package versions for the sample.
docs/mediator-framework/progress/tasks/README.md Updates Azure Functions task tracking state/links.
docs/mediator-framework/progress/tasks/azure-functions/AZF-07-one-way-rebus.md Marks AZD-08 as decided in acceptance checklist.
docs/mediator-framework/guide/rebus.md Documents outbound-only host rules and switches example to IBus.Send.
Directory.Packages.props Adds Microsoft.Azure.Functions.Worker.Sdk version centrally.
Ark.Tools.slnx Adds the new sample processor and Functions host projects to the solution.

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

@AndreaCuneo

Copy link
Copy Markdown
Contributor

@copilot Fix the code for all comments in this review thread.

Do not make changes beyond what is described in the linked review thread.

Review the comments, they could be false positive.

… in hosted service

Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 13:31
Copilot AI requested a review from AndreaCuneo August 3, 2026 13:32
@AndreaCuneo

Copy link
Copy Markdown
Contributor

@copilot merge master changes

…ion-task

Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 13:39

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot merge master changes

Merged master into the branch in dc5a35a.

@AndreaCuneo

Copy link
Copy Markdown
Contributor

@copilot fix ci error

…containers

Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot August 3, 2026 14:02

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix ci error

Fixed in the latest commit. The CI failure was TimeoutException: The composed greeting was not completed within 10 seconds in the async Rebus composition test.

Root cause: after splitting into two separate containers, each created its own InMemoryGreetingStore. The API container wrote and read from store A; the processor container updated store B — so the API never saw the completion.

Fix: create one shared InMemoryGreetingStore in SampleTestContext when not using SQL (same pattern as InMemNetwork) and thread it through SampleComposition.BuildContainerSampleStartupSampleBusHostedServiceRebusProcessorComposition.BuildContainerApplicationComposition.Register. For SQL runs the two containers share the database as before.

@AndreaCuneo
AndreaCuneo merged commit 610e354 into master Aug 3, 2026
6 checks passed
@AndreaCuneo
AndreaCuneo deleted the copilot/azure-function-task branch August 3, 2026 14:19
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.

3 participants