Integration Events extend MASA Framework’s EventBus to cross process and service boundaries. Where in-process EventBus delivers events within a single application, IntegrationEvents publish messages to an external broker — backed by Dapr’s pub/sub building block — so that any subscribed service in your mesh can react. The outbox pattern ensures no events are silently lost between your database commit and the broker publish.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/masastack/MASA.Framework/llms.txt
Use this file to discover all available pages before exploring further.
Installation
Install the core integration events package plus your chosen transport and persistence adapter:Core Abstractions
IIntegrationEvent
Every integration event must implement IIntegrationEvent, which extends three interfaces:
IEvent— base event marker (shared with in-process EventBus)ITopic— carries the pub/sub topic nameITransaction— links to the current unit-of-work
IntegrationEvent Abstract Record
IntegrationEvent is the recommended base class. It pre-implements IIntegrationEvent and provides:
| Property | Type | Description |
|---|---|---|
EventId | Guid | Unique event identifier, auto-generated |
EvenCreateTime | DateTime | UTC creation timestamp, auto-set |
Topic | string | Defaults to the class name; override to customise |
UnitOfWork | IUnitOfWork? | Injected by the framework before publishing |
IIntegrationEventBus
IIntegrationEventBus extends IEventBus with the same PublishAsync<TEvent> signature. Internally it routes integration events through the outbox and Dapr transport while routing domain events to the local EventBus.
Defining an Integration Event
Registration
Wire up the integration event bus, Dapr transport, and EF Core event log inProgram.cs:
IntegrationEventLogService is the default EF Core implementation provided by
Masa.Contrib.Dispatcher.IntegrationEvents.EventLogs.EFCore. Supply your own
IIntegrationEventLogService implementation if you need a different persistence strategy.EF Core Migration
The event log creates its own table in yourDbContext. Apply migrations after registration:
Publishing an Integration Event
InjectIIntegrationEventBus and publish exactly as you would with the local EventBus:
Outbox Pattern — How It Works
The outbox pattern decouples your database commit from the broker publish in three steps:Store
When you call
PublishAsync, the event is serialised and saved to the IntegrationEventLog table inside the same transaction as your business write.Relay
IntegrationEventHostedService (a background service registered automatically) polls for pending events and forwards them to the Dapr pub/sub sidecar.Subscribing to an Integration Event
Subscribers use the standard Dapr[Topic] attribute on a controller action. No MASA-specific packages are required on the subscriber side:
[Topic] must match the Dapr pub/sub component name configured in your Dapr component YAML (pubsub by default in local development).
Background Retry Processor
IntegrationEventHostedService is registered automatically when you call AddIntegrationEventBus. It runs on a configurable interval and:
- Queries events in
NotPublishedorPublishedFailedstate. - Attempts to publish each event via the configured transport.
- Updates the event state to
Publishedon success or increments the retry counter on failure.
Custom IIntegrationEventLogService
If you need a non-EF Core persistence backend, implement IIntegrationEventLogService directly:
IntegrationEventLogService: