Implementing Policy / Reaction

77 views
Skip to first unread message

Zoltan Horkay

unread,
Jan 4, 2022, 5:02:25 AM1/4/22
to EventStorming
Hi Everyone,

I am currently re-factoring / re-designing an existing monolithic application. We used Event storming and DDD to capture commands, events, aggregates, external services, queries, and policies/reactions.

Our biggest challenge is modeling and implementing a chain of events.
Example: command (User Login) -> event1(credential validation) -> event2(risk assessment) -> event3(secondary validation)

The way how we logically modeled it: 
command -> aggregate1 -> event1 -> policy1 -> command2 -> aggregate2 -> event2 -> policy2 -> command3 -> aggregate3 -> event3

We have learnt an event cannot raise another event or command but only a policy (reaction) could do that. From a modeling perspective, it is not a big deal, however, we would like to do a POC and implement it using some framework.

In the case of separating the 3 aggregates into 3 different Microservice, it is pretty straightforward using a Message Bus and subscribing to the respective events. 

However, it is unclear to me what's happening if the 3 aggregates are within the same bounded contexts and we should implement the so-called Policy / Reaction component.
Options I found:
1. Message Bus - treat the domain events as the integration events
2. SAGA pattern.

Both options seem to be a bit overkill. 
Is there any best practice in terms of implementation Policy / Reaction in case all the events are within the same bounded context?

Many Thanks
Zoltan

Reply all
Reply to author
Forward
0 new messages