Search code examples
eventsmicroservicesdomain-driven-designdomain-events

call another microservice after a domain event occurs in DDD


I have an API for register users in "user service" after creating a user happen an event for send a welcome email. This requires the "user service" to call "the notification service". I have 3 layers in my project (Application - Domain - Infrastructure), in the user register API first application layer call domain layer and "create User Event" Occurs within the domain.

Should be the domain return the event to the application layer that sends to the application layer and application layer send this event to the infrastructure layer and infrastructure layer call notification service?

or should be the domain send the event directly to the infrastructure layer?

Which layer should be call the infrastructure layer for send data to the notification service?


Solution

  • I would make the Application layer in charge of calling Infra for notification, so your Domain don't have to bother about notifying what, when, how, etc.

    And the less Domain has reponsabilities, the better, I think.