domain-driven-designsequence-diagramhexagonal-architecture

Hexagonal architecture - sequence of calls


I'm trying to understand hexagonal architecture along with domain-driven design, but I'm confused with command handlers and command buses. Whether this should belong to the application layer or the domain layer?

Also, I could not find any example class or sequence diagrams. Appreciate if someone could provide a sample sequence diagram which also involves command buses.


Solution

  • I would argue that your command handlers will represent your application's API and, therefore, are part of your application 'layer'. These handlers will orchestrate domain objects and services.

    IMHO, the command bus is different. I have implemented an hexagonal architecture using a Command Processor pattern. This was essentially a port, implemented as a .Net interface in the application layer. I initially designed it as a bus but went with 'port' interfaces representing a Command Processor and an Event Publisher as these were more abstract and allowed me to use different styles of adapter, including something like NServiceBus.

    enter image description here