Problem: You can use event-driven architecture to solve the distributed data management challenges in a microservices architecture. However, one major challenge with implementing an event-driven architecture is atomically updating the database and publishing an event. Consider, for example, the Create Order use case. The service that implements this use case must perform two operations: insert a row into the ORDER table and publish an OrderCreated event. It is essential that both operations are done atomically. If only one operation happened because of a failure then the system would behave incorrectly.
The standard way to atomically is to use a distributed transaction involving a database and a message broker. However, for the reasons described earlier this is exactly what we do not want to do.
Event Sourcing is an architectural pattern.