jvz / akka-blog-example

Example on implementing a simple blog microservice using Akka and Scala
Apache License 2.0
33 stars 10 forks source link

Multi Entity Commands #3

Open two10 opened 6 years ago

two10 commented 6 years ago

Hello,

I am new to Event Sourcing and CQRS.

In the example if i have a command which says merge two blog and make a new blow which constains all posts of blog 1 and blog 2 and mark other two blogs as defunct.

In this kind of scenario, how should i implement Event Sourcing and CQRS and maintain consistency

jvz commented 6 years ago

Using the style from the example here, you may wish to consider making a specific command object for your use case which generates multiple events. The main source of consistency in event sourcing is by strict validation of commands before generating events from them.

Overall, maintaining consistency in event sourcing revolves around ensuring that only valid events are generated. If you need to roll back data, though, you can generally handle this by creating compensating transactions.