Skip to content

Commit eb2a232

Browse files
author
Serdar Hamzaoğulları
committed
README edited
1 parent 4b3435c commit eb2a232

File tree

3 files changed

+277
-2
lines changed

3 files changed

+277
-2
lines changed

event-sourcing/README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,31 @@ layout: pattern
33
title: Event Sourcing
44
folder: event-sourcing
55
permalink: /patterns/event-sourcing/
6-
categories: Concurrency
6+
categories: Architectural
77
tags:
88
- Java
99
- Difficulty Intermediate
1010
- Performance
1111
---
1212

1313
## Intent
14+
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.
15+
16+
![alt text](./etc/event-sourcing.png "Event Sourcing")
1417

1518
## Applicability
1619
Use the Event Sourcing pattern when
1720

18-
* You have a limited accesibility resource and the asynchronous process is acceptable to reach that
21+
* You need very high performance on persisting your application state even your application state have a complex relational data structure
22+
* You need log of changes of your application state and ability to restore a state of any moment in time.
23+
* You need to debug production problems by replaying the past events.
24+
25+
## Real world examples
26+
27+
* [The Lmax Architecture] (https://martinfowler.com/articles/lmax.html)
1928

2029
## Credits
2130

31+
* [Martin Fowler - Event Sourcing] (https://martinfowler.com/eaaDev/EventSourcing.html)
32+
* [Event Sourcing | Microsoft Docs] (https://docs.microsoft.com/en-us/azure/architecture/patterns/event-sourcing)
33+
* [Reference 3: Introducing Event Sourcing] (https://msdn.microsoft.com/en-us/library/jj591559.aspx)
103 KB
Loading
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<class-diagram version="1.2.0" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
3+
realizations="true" associations="true" dependencies="false" nesting-relationships="true" router="FAN">
4+
<class id="1" language="java" name="com.iluwatar.event.sourcing.api.DomainEvent" project="event-sourcing"
5+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/api/DomainEvent.java" binary="false"
6+
corner="BOTTOM_RIGHT">
7+
<position height="-1" width="-1" x="802" y="455"/>
8+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
9+
sort-features="false" accessors="true" visibility="true">
10+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
11+
<operations public="true" package="true" protected="true" private="true" static="true"/>
12+
</display>
13+
</class>
14+
<interface id="2" language="java" name="com.iluwatar.event.sourcing.api.EventProcessor" project="event-sourcing"
15+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/api/EventProcessor.java" binary="false"
16+
corner="BOTTOM_RIGHT">
17+
<position height="-1" width="-1" x="451" y="273"/>
18+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
19+
sort-features="false" accessors="true" visibility="true">
20+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
21+
<operations public="true" package="true" protected="true" private="true" static="true"/>
22+
</display>
23+
</interface>
24+
<interface id="3" language="java" name="com.iluwatar.event.sourcing.api.ProcessorJournal" project="event-sourcing"
25+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/api/ProcessorJournal.java" binary="false"
26+
corner="BOTTOM_RIGHT">
27+
<position height="-1" width="-1" x="134" y="275"/>
28+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
29+
sort-features="false" accessors="true" visibility="true">
30+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
31+
<operations public="true" package="true" protected="true" private="true" static="true"/>
32+
</display>
33+
</interface>
34+
<class id="4" language="java" name="com.iluwatar.event.sourcing.domain.Account" project="event-sourcing"
35+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/domain/Account.java" binary="false"
36+
corner="BOTTOM_RIGHT">
37+
<position height="-1" width="-1" x="444" y="1120"/>
38+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
39+
sort-features="false" accessors="true" visibility="true">
40+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
41+
<operations public="true" package="true" protected="true" private="true" static="true"/>
42+
</display>
43+
</class>
44+
<class id="5" language="java" name="com.iluwatar.event.sourcing.domain.Transaction" project="event-sourcing"
45+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/domain/Transaction.java" binary="false"
46+
corner="BOTTOM_RIGHT">
47+
<position height="-1" width="-1" x="821" y="1121"/>
48+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
49+
sort-features="false" accessors="true" visibility="true">
50+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
51+
<operations public="true" package="true" protected="true" private="true" static="true"/>
52+
</display>
53+
</class>
54+
<class id="6" language="java" name="com.iluwatar.event.sourcing.processor.DomainEventProcessor"
55+
project="event-sourcing"
56+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/processor/DomainEventProcessor.java" binary="false"
57+
corner="BOTTOM_RIGHT">
58+
<position height="-1" width="-1" x="452" y="475"/>
59+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
60+
sort-features="false" accessors="true" visibility="true">
61+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
62+
<operations public="true" package="true" protected="true" private="true" static="true"/>
63+
</display>
64+
</class>
65+
<class id="7" language="java" name="com.iluwatar.event.sourcing.journal.JsonFileJournal" project="event-sourcing"
66+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/journal/JsonFileJournal.java" binary="false"
67+
corner="BOTTOM_RIGHT">
68+
<position height="-1" width="-1" x="134" y="499"/>
69+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
70+
sort-features="false" accessors="true" visibility="true">
71+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
72+
<operations public="true" package="true" protected="true" private="true" static="true"/>
73+
</display>
74+
</class>
75+
<class id="8" language="java" name="com.iluwatar.event.sourcing.event.AccountCreateEvent" project="event-sourcing"
76+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/event/AccountCreateEvent.java" binary="false"
77+
corner="BOTTOM_RIGHT">
78+
<position height="-1" width="-1" x="138" y="749"/>
79+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
80+
sort-features="false" accessors="true" visibility="true">
81+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
82+
<operations public="true" package="true" protected="true" private="true" static="true"/>
83+
</display>
84+
</class>
85+
<class id="9" language="java" name="com.iluwatar.event.sourcing.event.MoneyDepositEvent" project="event-sourcing"
86+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/event/MoneyDepositEvent.java" binary="false"
87+
corner="BOTTOM_RIGHT">
88+
<position height="-1" width="-1" x="473" y="745"/>
89+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
90+
sort-features="false" accessors="true" visibility="true">
91+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
92+
<operations public="true" package="true" protected="true" private="true" static="true"/>
93+
</display>
94+
</class>
95+
<class id="10" language="java" name="com.iluwatar.event.sourcing.event.MoneyTransferEvent" project="event-sourcing"
96+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/event/MoneyTransferEvent.java" binary="false"
97+
corner="BOTTOM_RIGHT">
98+
<position height="-1" width="-1" x="802" y="766"/>
99+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
100+
sort-features="false" accessors="true" visibility="true">
101+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
102+
<operations public="true" package="true" protected="true" private="true" static="true"/>
103+
</display>
104+
</class>
105+
<class id="11" language="java" name="com.iluwatar.event.sourcing.event.MoneyWithdrawalEvent" project="event-sourcing"
106+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/event/MoneyWithdrawalEvent.java" binary="false"
107+
corner="BOTTOM_RIGHT">
108+
<position height="-1" width="-1" x="1107" y="748"/>
109+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
110+
sort-features="false" accessors="true" visibility="true">
111+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
112+
<operations public="true" package="true" protected="true" private="true" static="true"/>
113+
</display>
114+
</class>
115+
<class id="12" language="java" name="com.iluwatar.event.sourcing.state.AccountAggregate" project="event-sourcing"
116+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/state/AccountAggregate.java" binary="false"
117+
corner="BOTTOM_RIGHT">
118+
<position height="-1" width="-1" x="97" y="1120"/>
119+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
120+
sort-features="false" accessors="true" visibility="true">
121+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
122+
<operations public="true" package="true" protected="true" private="true" static="true"/>
123+
</display>
124+
</class>
125+
<class id="13" language="java" name="com.iluwatar.event.sourcing.service.AccountService" project="event-sourcing"
126+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/service/AccountService.java" binary="false"
127+
corner="BOTTOM_RIGHT">
128+
<position height="-1" width="-1" x="687" y="68"/>
129+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
130+
sort-features="false" accessors="true" visibility="true">
131+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
132+
<operations public="true" package="true" protected="true" private="true" static="true"/>
133+
</display>
134+
</class>
135+
<class id="14" language="java" name="com.iluwatar.event.sourcing.service.MoneyTransactionService"
136+
project="event-sourcing"
137+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/service/MoneyTransactionService.java" binary="false"
138+
corner="BOTTOM_RIGHT">
139+
<position height="-1" width="-1" x="178" y="88"/>
140+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
141+
sort-features="false" accessors="true" visibility="true">
142+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
143+
<operations public="true" package="true" protected="true" private="true" static="true"/>
144+
</display>
145+
</class>
146+
<class id="15" language="java" name="com.iluwatar.event.sourcing.gateway.Gateways" project="event-sourcing"
147+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/gateway/Gateways.java" binary="false"
148+
corner="BOTTOM_RIGHT">
149+
<position height="-1" width="-1" x="476" y="1484"/>
150+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
151+
sort-features="false" accessors="true" visibility="true">
152+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
153+
<operations public="true" package="true" protected="true" private="true" static="true"/>
154+
</display>
155+
</class>
156+
<class id="16" language="java" name="com.iluwatar.event.sourcing.gateway.AccountCreateContractSender"
157+
project="event-sourcing"
158+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/gateway/AccountCreateContractSender.java"
159+
binary="false" corner="BOTTOM_RIGHT">
160+
<position height="-1" width="-1" x="920" y="1483"/>
161+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
162+
sort-features="false" accessors="true" visibility="true">
163+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
164+
<operations public="true" package="true" protected="true" private="true" static="true"/>
165+
</display>
166+
</class>
167+
<class id="17" language="java" name="com.iluwatar.event.sourcing.gateway.TransactionLogger" project="event-sourcing"
168+
file="/event-sourcing/src/main/java/com/iluwatar/event/sourcing/gateway/TransactionLogger.java" binary="false"
169+
corner="BOTTOM_RIGHT">
170+
<position height="-1" width="-1" x="94" y="1484"/>
171+
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
172+
sort-features="false" accessors="true" visibility="true">
173+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
174+
<operations public="true" package="true" protected="true" private="true" static="true"/>
175+
</display>
176+
</class>
177+
<generalization id="18">
178+
<end type="SOURCE" refId="8"/>
179+
<end type="TARGET" refId="1"/>
180+
</generalization>
181+
<generalization id="19">
182+
<end type="SOURCE" refId="10"/>
183+
<end type="TARGET" refId="1"/>
184+
</generalization>
185+
<association id="20">
186+
<end type="SOURCE" refId="4" navigable="false">
187+
<attribute id="21" name="transactions"/>
188+
<multiplicity id="22" minimum="0" maximum="2147483647"/>
189+
</end>
190+
<end type="TARGET" refId="5" navigable="true"/>
191+
<display labels="true" multiplicity="true"/>
192+
</association>
193+
<association id="23">
194+
<end type="SOURCE" refId="6" navigable="false">
195+
<attribute id="24" name="precessorJournal"/>
196+
<multiplicity id="25" minimum="0" maximum="1"/>
197+
</end>
198+
<end type="TARGET" refId="3" navigable="true"/>
199+
<display labels="true" multiplicity="true"/>
200+
</association>
201+
<association id="26">
202+
<end type="SOURCE" refId="15" navigable="false">
203+
<attribute id="27" name="transactionLogger"/>
204+
<multiplicity id="28" minimum="0" maximum="1"/>
205+
</end>
206+
<end type="TARGET" refId="17" navigable="true"/>
207+
<display labels="true" multiplicity="true"/>
208+
</association>
209+
<generalization id="29">
210+
<end type="SOURCE" refId="11"/>
211+
<end type="TARGET" refId="1"/>
212+
</generalization>
213+
<association id="30">
214+
<end type="SOURCE" refId="13" navigable="false">
215+
<attribute id="31" name="eventProcessor"/>
216+
<multiplicity id="32" minimum="0" maximum="1"/>
217+
</end>
218+
<end type="TARGET" refId="2" navigable="true"/>
219+
<display labels="true" multiplicity="true"/>
220+
</association>
221+
<realization id="33">
222+
<end type="SOURCE" refId="6"/>
223+
<end type="TARGET" refId="2"/>
224+
</realization>
225+
<association id="34">
226+
<end type="SOURCE" refId="15" navigable="false">
227+
<attribute id="35" name="accountCreateContractSender"/>
228+
<multiplicity id="36" minimum="0" maximum="1"/>
229+
</end>
230+
<end type="TARGET" refId="16" navigable="true"/>
231+
<display labels="true" multiplicity="true"/>
232+
</association>
233+
<realization id="37">
234+
<end type="SOURCE" refId="7"/>
235+
<end type="TARGET" refId="3"/>
236+
</realization>
237+
<association id="38">
238+
<end type="SOURCE" refId="12" navigable="false">
239+
<attribute id="39" name="accounts"/>
240+
<multiplicity id="40" minimum="0" maximum="2147483647"/>
241+
</end>
242+
<end type="TARGET" refId="4" navigable="true"/>
243+
<display labels="true" multiplicity="true"/>
244+
</association>
245+
<generalization id="41">
246+
<end type="SOURCE" refId="9"/>
247+
<end type="TARGET" refId="1"/>
248+
</generalization>
249+
<association id="42">
250+
<end type="SOURCE" refId="14" navigable="false">
251+
<attribute id="43" name="eventProcessor"/>
252+
<multiplicity id="44" minimum="0" maximum="1"/>
253+
</end>
254+
<end type="TARGET" refId="2" navigable="true"/>
255+
<display labels="true" multiplicity="true"/>
256+
</association>
257+
<classifier-display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
258+
sort-features="false" accessors="true" visibility="true">
259+
<attributes public="true" package="true" protected="true" private="true" static="true"/>
260+
<operations public="true" package="true" protected="true" private="true" static="true"/>
261+
</classifier-display>
262+
<association-display labels="true" multiplicity="true"/>
263+
</class-diagram>

0 commit comments

Comments
 (0)