【实现领域驱动设计】领域事件

事件发布

【实现领域驱动设计】领域事件_第1张图片

@startuml
autonumber 

skinparam sequence {
ArrowColor red
LifeLineBorderColor black
LifeLineBackgroundColor #A9DCDF

ParticipantBorderColor DeepSkyBlue
ParticipantBackgroundColor Gold
ParticipantFontName Impact
ParticipantFontSize 15
ParticipantFontColor grey
}

participant UserInterface
participant ApplicationService
participant DomainEventSubscriber
participant DomainEventPublisher
participant Aggregate

UserInterface -> DomainEventPublisher: reset()
activate UserInterface
activate DomainEventPublisher
UserInterface -> ApplicationService: doCommand()
activate ApplicationService
ApplicationService -> DomainEventSubscriber: new
ApplicationService -> DomainEventPublisher: subscribe()
ApplicationService -> Aggregate: command()
activate Aggregate
Aggregate -> Event:new
Aggregate -> DomainEventPublisher: publish()
deactivate Aggregate
DomainEventPublisher -> DomainEventSubscriber:subscribedToEventType()
activate DomainEventSubscriber
DomainEventPublisher -> DomainEventSubscriber: handleEvent()
deactivate DomainEventSubscriber

@enduml

事件存储

【实现领域驱动设计】领域事件_第2张图片

@startuml
autonumber 

skinparam sequence {
ArrowColor red
LifeLineBorderColor black
LifeLineBackgroundColor #A9DCDF

ParticipantBorderColor DeepSkyBlue
ParticipantBackgroundColor Gold
ParticipantFontName Impact
ParticipantFontSize 15
ParticipantFontColor grey
}

participant IdentityAccessEventProcessor
participant DomainEventSubscriber
participant EventStore
participant StoredEvent
participant DomainEventPublisher
participant ObjectSerializer
participant Session

activate IdentityAccessEventProcessor
IdentityAccessEventProcessor -> DomainEventSubscriber: new
activate DomainEventSubscriber
IdentityAccessEventProcessor -> DomainEventPublisher: subscribe()
activate DomainEventPublisher
DomainEventPublisher -> DomainEventSubscriber: handleEvent():\n Aggregate command publishes Event...
deactivate DomainEventPublisher
DomainEventSubscriber -> EventStore: append()
activate EventStore
EventStore -> ObjectSerializer: serialize()
activate ObjectSerializer
deactivate ObjectSerializer
EventStore -> StoredEvent: new
activate StoredEvent
deactivate StoredEvent
EventStore -> Session: save()
activate Session
deactivate Session

@enduml

你可能感兴趣的:(架构)