Skip to main content

Employee Event Publishing Flow

Summary

Employee changes and their integration-event outbox messages are staged by one SaveChangesAsync call. Actual relay invocation from Employee Service is not confirmed.

Audience

  • Backend developers, QA engineers, and solution architects

Overview

EmployeeDbContext.SaveChangesAsync inspects tracked aggregate roots, maps each queued domain event, serializes the resulting shared record, adds an outbox entity, clears the aggregate event list, and then delegates to EF Core persistence.

Employee-created sequence

Mapping behavior

All seven known Employee domain events are handled by the mapping switch. The mapping enriches some projection contracts with locally available organization names and derives an optional Legacy employee reference from the employee code. This is current implementation behavior, not a guaranteed external parsing rule.

The mapper creates new integration-event IDs. It sets the event type and schema version explicitly. Domain events are cleared before the EF save completes; if persistence fails, the tracked aggregate instance no longer retains them. Recovery behavior for that in-memory condition Requires confirmation.

Publication boundary

The shared OutboxProcessor reads eligible messages, calls the event bus, and marks successful entries processed or failed attempts failed. AddHrSuitMessaging registers the processor and publisher abstractions but does not schedule processing. Employee Service registers its outbox store but no hosted service or endpoint that invokes the processor was found.

Source References

  • microservices/src/employee-service/Domain/Employees/Employee.cs
  • microservices/src/employee-service/Infrastructure/EmployeeDbContext.cs
  • microservices/src/employee-service/Infrastructure/Persistence.cs
  • microservices/src/employee-service/Program.cs
  • microservices/src/shared-kernel/Outbox/IntegrationEventJsonSerializer.cs
  • microservices/src/shared-kernel/Messaging/OutboxProcessor.cs
  • microservices/src/shared-kernel/Extensions/MessagingExtensions.cs

See Also

Keywords

  • SaveChanges mapping
  • Transactional staging
  • Publisher boundary

Revision Information

  • Status: Draft
  • Last reviewed: 2026-07-15
  • Review cycle: Quarterly