Skip to content

Remove MediatR and simplify ordering workflows - #1091

Draft
DamianEdwards wants to merge 4 commits into
mainfrom
damianedwards-remove-mediatr
Draft

DamianEdwards wants to merge 4 commits into
mainfrom
damianedwards-remove-mediatr

Conversation

@DamianEdwards

@DamianEdwards DamianEdwards commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Motivation

Remove MediatR entirely by simplifying Ordering's application flow, rather than introducing another mediator or dispatch abstraction. Order processing is now explicit and easier to follow from HTTP endpoints and integration-event handlers.

Approach

  • Consolidate command handlers and domain-event callbacks into one concrete OrderApplicationService with explicit operations.
  • Keep aggregate business rules, command validation, request deduplication, logging, execution-strategy retries, and transactional integration-event outbox handling.
  • Coordinate buyer/payment updates directly and persist generated IDs before linking them to orders. Publish integration events only after commit.
  • Remove MediatR packages, registration, pipeline behaviors, identified-command wrappers, and internal domain-event machinery.
  • Roll back failed operations and clear tracked state before retrying. Add SQLite relational regression coverage, PostgreSQL-backed HTTP coverage, and workflow documentation.
  • Make Ordering's outbox event assembly explicit so deserialization also works when the API runs inside a different entry-point host, such as functional tests.

Validation

  • dotnet build eShop.Web.slnf --nologo -v:q passed, with existing dependency advisory warnings.
  • Ordering unit tests: 56 passed, including transaction-start, request-registration, commit-failure rollback, and retry coverage.
  • PostgreSQL-backed Ordering functional tests: 13 passed, including valid-order persistence/deduplication and the HTTP 500 infrastructure-failure regression.
  • Confirmed no MediatR references in source and no MediatR packages in the restored Ordering.API dependency graph.

Review follow-up

Addressed the Opus finding about infrastructure failures being converted into successful checkout responses. Only validation and domain exceptions retain the existing boolean failure result for identified operations. Database, transaction, and other infrastructure exceptions propagate to HTTP 500 rather than acknowledging an order that was not saved.

DamianEdwards and others added 2 commits November 16, 2026 15:09
Consolidate command and domain-event handling into explicit order application service operations. Retain validation, request deduplication, transaction retries, and integration-event outbox behavior, with focused relational and PostgreSQL regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread README.md

## Ordering workflows

The Ordering API calls a concrete `OrderApplicationService` directly from its HTTP endpoints and integration-event handlers. The service validates commands, deduplicates client requests, and coordinates buyer, payment, and order updates within a database transaction. Domain aggregates enforce their business rules without internal event dispatch. Integration events are saved to the outbox in the same transaction and published only after commit.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this needed in the main README?

DamianEdwards and others added 2 commits November 16, 2026 15:24
Limit identified-operation failure results to validation and domain exceptions so database and transaction failures reach HTTP 500. Cover transaction start, request registration, commit rollback, and the HTTP error contract. Make Ordering's outbox event assembly explicit for correct deserialization under hosted execution.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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