Java Magazine, Jan/Feb 2018
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2018 70 beyond CRUD same time some other use case updates their account balance If this information affects the same database entries the two activities lead to a locking situation Usually this optimistic locking results in one transaction winning over the other However strictly speaking there should be no need to mutually exclude either transaction Because the real world is all about distributed collaboration often in an asynchronous way it makes sense to model applications in an event driven way A similar problem occurs when a use case updates business objects whose new states require verification to keep the system in a consistent state Verifying and maintaining these consistent states can become both redundant and complex Because CRUD based applications need to store the status quo and keep a consistent state within their data model they cannot scale horizontally To maintain consistency such applications need to lock the data as in good old atomicity consistency isolation and durability ACID transactions until the update has taken place If several distributed systems are involved the synchronization will become a bottleneck Event Sourcing In contrast to a CRUD data model event sourced systems store all modifications that happen to a system as atomic entities The application does not necessarily contain the current state but it can be calculated by applying all events that have happened in the past These events are the single source of truth in the system The most prominent example for this model is bank accounts You can calculate your current balance by starting at zero and adding or subtracting the amounts of all transactions accordingly The example in Figure 1 shows a simple set of customer related events that can be used to arrive at a customer representation The events are atomic and immutable because they happened in the past and cannot be undone This implies that for example a deletion action also changes the current state by just adding a CustomerDeleted event to the log no entry is actually deleted
You must have JavaScript enabled to view digital editions.