Asset Event Architecture
Summary
The verified pipeline that carries an asset lifecycle change from an in-memory domain event to a published integration contract, including the components that are registered in the service host.
Audience
Engineering, integration, QA, architecture, and security reviewers.
Reference Content
Components
| Component | Type | Role | Source |
|---|---|---|---|
AssetDomainEventBase and six records | Domain event | Raised by the aggregate on transitions | Domain/Asset/AssetDomainEvents.cs |
AggregateRoot | Domain primitive | Holds DomainEvents, Raise, ClearDomainEvents | Domain/Common/DomainPrimitives.cs |
AssetDbContext.DispatchDomainEventsToOutbox | Infrastructure | Maps domain events to contracts on save | Infrastructure/AssetDbContext.cs |
IntegrationEventJsonSerializer | Shared kernel | Serializes a contract into an outbox row | shared-kernel/Outbox/IntegrationEventJsonSerializer.cs |
OutboxMessage | Shared kernel | The staged outbox row | shared-kernel/Outbox/OutboxMessage.cs |
OutboxRelayHostedService | Hosted service | Polls the outbox every 10 seconds | Messaging/OutboxRelayHostedService.cs |
OutboxProcessor | Shared kernel | Publishes pending/failed rows | shared-kernel/Messaging/OutboxProcessor.cs |
RabbitMqEventBus | Shared kernel | Publishes to the broker | shared-kernel/Messaging/RabbitMqEventBus.cs |
Host registration (verified)
Program.cs calls AddHrSuitMessaging(...), which registers the shared event bus, the integration-event publisher, and a scoped IOutboxProcessor that resolves to the real OutboxProcessor when an IOutboxMessageStore is present (asset-service registers AssetOutboxMessageStore). Program.cs also registers OutboxRelayHostedService as a hosted service. The relay resolves the processor in its own scope per iteration.
Pipeline
Design boundaries
- The map and completeness guard run before commit; a gap throws and rolls back the whole change.
- Publishing happens after commit, asynchronously, on the relay thread. A publish failure never blocks the request that wrote the row.
- Broker reachability is environment-dependent. This documentation does not connect to messaging infrastructure and does not verify end-to-end broker delivery.
Source References
microservices/src/asset-service/Infrastructure/AssetDbContext.csmicroservices/src/asset-service/Messaging/OutboxRelayHostedService.csmicroservices/src/shared-kernel/Messaging/OutboxProcessor.csmicroservices/src/shared-kernel/Extensions/MessagingExtensions.csmicroservices/src/asset-service/Program.cs
Related Articles
See Also
Keywords
- Event architecture
- Outbox relay
- Domain event dispatch
Revision Information
- Status: Draft
- Last reviewed: 2026-07-17
- Review cycle: Quarterly