Skip to content

Commit

Permalink
README edited
Browse files Browse the repository at this point in the history
  • Loading branch information
Serdar Hamzaoğulları committed Aug 12, 2017
1 parent 4b3435c commit eb2a232
Show file tree
Hide file tree
Showing 3 changed files with 277 additions and 2 deletions.
16 changes: 14 additions & 2 deletions event-sourcing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,31 @@ layout: pattern
title: Event Sourcing
folder: event-sourcing
permalink: /patterns/event-sourcing/
categories: Concurrency
categories: Architectural
tags:
- Java
- Difficulty Intermediate
- Performance
---

## Intent
Instead of storing just the current state of the data in a domain, use an append-only store to record the full series of actions taken on that data. The store acts as the system of record and can be used to materialize the domain objects. This can simplify tasks in complex domains, by avoiding the need to synchronize the data model and the business domain, while improving performance, scalability, and responsiveness. It can also provide consistency for transactional data, and maintain full audit trails and history that can enable compensating actions.

![alt text](./etc/event-sourcing.png "Event Sourcing")

## Applicability
Use the Event Sourcing pattern when

* You have a limited accesibility resource and the asynchronous process is acceptable to reach that
* You need very high performance on persisting your application state even your application state have a complex relational data structure
* You need log of changes of your application state and ability to restore a state of any moment in time.
* You need to debug production problems by replaying the past events.

## Real world examples

* [The Lmax Architecture] (https://martinfowler.com/articles/lmax.html)

## Credits

* [Martin Fowler - Event Sourcing] (https://martinfowler.com/eaaDev/EventSourcing.html)
* [Event Sourcing | Microsoft Docs] (https://docs.microsoft.com/en-us/azure/architecture/patterns/event-sourcing)
* [Reference 3: Introducing Event Sourcing] (https://msdn.microsoft.com/en-us/library/jj591559.aspx)
Binary file added event-sourcing/etc/event-sourcing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
263 changes: 263 additions & 0 deletions event-sourcing/etc/event-sourcing.ucls
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.2.0" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
<class id="1" language="java" name="com.iluwatar.event.sourcing.api.DomainEvent" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/api/DomainEvent.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="802" y="455"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="2" language="java" name="com.iluwatar.event.sourcing.api.EventProcessor" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/api/EventProcessor.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="451" y="273"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<interface id="3" language="java" name="com.iluwatar.event.sourcing.api.ProcessorJournal" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/api/ProcessorJournal.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="134" y="275"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="4" language="java" name="com.iluwatar.event.sourcing.domain.Account" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/domain/Account.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="444" y="1120"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="5" language="java" name="com.iluwatar.event.sourcing.domain.Transaction" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/domain/Transaction.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="821" y="1121"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="6" language="java" name="com.iluwatar.event.sourcing.processor.DomainEventProcessor"
project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/processor/DomainEventProcessor.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="452" y="475"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="7" language="java" name="com.iluwatar.event.sourcing.journal.JsonFileJournal" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/journal/JsonFileJournal.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="134" y="499"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="8" language="java" name="com.iluwatar.event.sourcing.event.AccountCreateEvent" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/event/AccountCreateEvent.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="138" y="749"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="9" language="java" name="com.iluwatar.event.sourcing.event.MoneyDepositEvent" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/event/MoneyDepositEvent.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="473" y="745"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="10" language="java" name="com.iluwatar.event.sourcing.event.MoneyTransferEvent" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/event/MoneyTransferEvent.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="802" y="766"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="11" language="java" name="com.iluwatar.event.sourcing.event.MoneyWithdrawalEvent" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/event/MoneyWithdrawalEvent.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="1107" y="748"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="12" language="java" name="com.iluwatar.event.sourcing.state.AccountAggregate" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/state/AccountAggregate.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="97" y="1120"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="13" language="java" name="com.iluwatar.event.sourcing.service.AccountService" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/service/AccountService.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="687" y="68"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="14" language="java" name="com.iluwatar.event.sourcing.service.MoneyTransactionService"
project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/service/MoneyTransactionService.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="178" y="88"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="15" language="java" name="com.iluwatar.event.sourcing.gateway.Gateways" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/gateway/Gateways.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="476" y="1484"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="16" language="java" name="com.iluwatar.event.sourcing.gateway.AccountCreateContractSender"
project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/gateway/AccountCreateContractSender.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="920" y="1483"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="17" language="java" name="com.iluwatar.event.sourcing.gateway.TransactionLogger" project="event-sourcing"
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/gateway/TransactionLogger.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="94" y="1484"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<generalization id="18">
<end type="SOURCE" refId="8"/>
<end type="TARGET" refId="1"/>
</generalization>
<generalization id="19">
<end type="SOURCE" refId="10"/>
<end type="TARGET" refId="1"/>
</generalization>
<association id="20">
<end type="SOURCE" refId="4" navigable="false">
<attribute id="21" name="transactions"/>
<multiplicity id="22" minimum="0" maximum="2147483647"/>
</end>
<end type="TARGET" refId="5" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="23">
<end type="SOURCE" refId="6" navigable="false">
<attribute id="24" name="precessorJournal"/>
<multiplicity id="25" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="3" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<association id="26">
<end type="SOURCE" refId="15" navigable="false">
<attribute id="27" name="transactionLogger"/>
<multiplicity id="28" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="17" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<generalization id="29">
<end type="SOURCE" refId="11"/>
<end type="TARGET" refId="1"/>
</generalization>
<association id="30">
<end type="SOURCE" refId="13" navigable="false">
<attribute id="31" name="eventProcessor"/>
<multiplicity id="32" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="33">
<end type="SOURCE" refId="6"/>
<end type="TARGET" refId="2"/>
</realization>
<association id="34">
<end type="SOURCE" refId="15" navigable="false">
<attribute id="35" name="accountCreateContractSender"/>
<multiplicity id="36" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="16" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="37">
<end type="SOURCE" refId="7"/>
<end type="TARGET" refId="3"/>
</realization>
<association id="38">
<end type="SOURCE" refId="12" navigable="false">
<attribute id="39" name="accounts"/>
<multiplicity id="40" minimum="0" maximum="2147483647"/>
</end>
<end type="TARGET" refId="4" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<generalization id="41">
<end type="SOURCE" refId="9"/>
<end type="TARGET" refId="1"/>
</generalization>
<association id="42">
<end type="SOURCE" refId="14" navigable="false">
<attribute id="43" name="eventProcessor"/>
<multiplicity id="44" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

0 comments on commit eb2a232

Please sign in to comment.