event sourcing with microservices
TRANSCRIPT
![Page 1: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/1.jpg)
Event Sourcing and Microservices
Why & How?
Ralph Winzinger Taipei, April 2016
![Page 2: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/2.jpg)
Senior Technical Leader
MicroservicesAgile
Architecture
Digital
RalphWinzinger
Cloud
![Page 3: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/3.jpg)
Microservices• small - not only in terms of „lines of code“ but regarding
its functionality and the effort it takes to maintain
• self-contained, autonomous
• independent deployment unit
• fault-tolerant / resilient
• lightweight, having a small footprint
• exclusive access to its datastore
![Page 4: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/4.jpg)
Microservices
• self contained
• fault-tolerant / resilient
• independent components
![Page 5: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/5.jpg)
Microservices
• self contained
• fault-tolerant / resilient
• independent components
TransactionService
CustomerService
AccountService
![Page 6: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/6.jpg)
Microservices
• self contained
• fault-tolerant / resilient
• independent components
TransactionService
CustomerService
AccountService
![Page 7: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/7.jpg)
Microservices
• self contained ???
• fault-tolerant / resilient ???
• independent components ???
TransactionService
CustomerService
AccountService
![Page 8: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/8.jpg)
Microservices
• self contained ???
• fault-tolerant / resilient ???
• independent components ???
TransactionService
CustomerService
AccountService
highly distributed systems!
![Page 9: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/9.jpg)
Microservices
• self contained ???
• fault-tolerant / resilient ???
• independent components ???
TransactionService
CustomerService
AccountService
highly distributed systems!
Availability?
![Page 10: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/10.jpg)
Microservices
• self contained ???
• fault-tolerant / resilient ???
• independent components ???
TransactionService
CustomerService
AccountService
highly distributed systems!
Availability?
Latency?
![Page 11: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/11.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime)
![Page 12: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/12.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime)
1 year = 8760 hours = 525600 minutes
![Page 13: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/13.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime)
1 year = 8760 hours = 525600 minutes
99% 88,5 hours downtime
![Page 14: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/14.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime)
1 year = 8760 hours = 525600 minutes
99,9% 8,8 hours downtime
![Page 15: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/15.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime)
1 year = 8760 hours = 525600 minutes
99,99% 53 minutes downtime
![Page 16: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/16.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime)
1 year = 8760 hours = 525600 minutes
99,999% 5 minutes downtime
![Page 17: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/17.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime)
1 year = 8760 hours = 525600 minutes
99,999% 5 minutes downtime
„five nines“high availability
![Page 18: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/18.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime) AS = AC(n-1) + ((1-AC(n-1))*ACn)
![Page 19: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/19.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime) AS = AC(n-1) + ((1-AC(n-1))*ACn)
S1
S2
S3
DB
FW
LB
![Page 20: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/20.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime) AS = AC(n-1) + ((1-AC(n-1))*ACn)
S1
S2
S3
DB
FW
LB
![Page 21: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/21.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime) AS = AC(n-1) + ((1-AC(n-1))*ACn)
S1
S2
S3
DB
99,5%
FW
LB 99,99%
99,99%
99,9%
99,9%
99,99%
![Page 22: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/22.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime) AS = AC(n-1) + ((1-AC(n-1))*ACn)
S1
S2
S3
DB
99,5%
FW
LB 99,99%
99,99%
99,9%
99,9%
99,99%
99,27% 64h downtime
![Page 23: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/23.jpg)
Availabilityfor eCommerce 24/7 systems
AV = Uptime / (Uptime + Downtime) AS = AC(n-1) + ((1-AC(n-1))*ACn)
S1
S2
S3
DB
99,5%
FW
LB 99,99%
99,99%
99,9%
99,9%
99,99%
99,27% 64h downtimewe don’t want dependencies
& communication
![Page 24: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/24.jpg)
LatencyThe more dependencies we have, the longer
our requests will take
![Page 25: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/25.jpg)
LatencyThe more dependencies we have, the longer
our requests will take
S1
S2
S3
DB
FW
LB
![Page 26: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/26.jpg)
LatencyThe more dependencies we have, the longer
our requests will take
S1
S2
S3
DB
FW
LB
![Page 27: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/27.jpg)
LatencyThe more dependencies we have, the longer
our requests will take
S1
S2
S3
DB
100 msec
FW
LB 5 msec
5 msec
100 msec
100 msec
5 msec
![Page 28: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/28.jpg)
LatencyThe more dependencies we have, the longer
our requests will take
S1
S2
S3
DB
100 msec
FW
LB 5 msec
5 msec
100 msec
100 msec
5 msec
315 ms
![Page 29: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/29.jpg)
LatencyThe more dependencies we have, the longer
our requests will take
S1
S2
S3
DB
100 msec
FW
LB 5 msec
5 msec
100 msec
100 msec
5 msec
315 mswe don’t want dependencies
& communication
![Page 30: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/30.jpg)
only data, not logicMicroservices contain all necessary
logic to process a request
![Page 31: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/31.jpg)
only data, not logicMicroservices contain all necessary
logic to process a request
But maybe we need some additional data from other services, some „facts“
![Page 32: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/32.jpg)
only data, not logic
• access the other service’ database
• keep data redundant
• low level database sync
• event sourcing
Microservices contain all necessary logic to process a request
But maybe we need some additional data from other services, some „facts“
![Page 33: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/33.jpg)
only data, not logic
• access the other service’ database
• keep data redundant
• low level database sync
• event sourcing
Microservices contain all necessary logic to process a request
But maybe we need some additional data from other services, some „facts“
NO !
![Page 34: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/34.jpg)
only data, not logic
• access the other service’ database
• keep data redundant
• low level database sync - also introduces coupling
• event sourcing
Microservices contain all necessary logic to process a request
But maybe we need some additional data from other services, some „facts“
NO !
![Page 35: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/35.jpg)
only data, not logic
• access the other service’ database
• keep data redundant
• low level database sync - also introduces coupling
• event sourcing
Microservices contain all necessary logic to process a request
But maybe we need some additional data from other services, some „facts“
NO !
![Page 36: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/36.jpg)
Domain Events• An important change in the state of our system.
Important with regard to business functionality.
• It happened in the past and it is immutable
• It is persistent
• The „sum“ of all events is the current system state
• It’s public for all services
![Page 37: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/37.jpg)
Domain Events• An important change in the state of our system.
Important with regard to business functionality.
• It happened in the past and it is immutable
• It is persistent
• The „sum“ of all events is the current system state
• It’s public for all services
CustomerCreatedEvent
AccountOpenedEvent
TransactionProcessedEvent
CustomerAddressChangedEvent
![Page 38: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/38.jpg)
Account BalanceMicroservices have exactly one thing to do.
They have one business functionality.
![Page 39: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/39.jpg)
Account BalanceMicroservices have exactly one thing to do.
They have one business functionality.
Transactionsamount
Customer[accounts]
Accountbalance
![Page 40: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/40.jpg)
Account BalanceThe balance depends on transactions.
Where can I find the current account balance?
Transactionsamount
Customer[accounts]
Accountbalance
![Page 41: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/41.jpg)
Account BalanceThe balance depends on transactions.
Where can I find the current account balance?
• select balance from acc where accno=18773
![Page 42: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/42.jpg)
Account BalanceLet’s assume we have a TransactionProcessedEvent
that is created each time, the TransactionService processed a transaction
![Page 43: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/43.jpg)
Account BalanceLet’s assume we have a TransactionProcessedEvent
that is created each time, the TransactionService processed a transaction
TransactionService
DB
Online Banking
Mobile Banking
![Page 44: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/44.jpg)
Account BalanceLet’s assume we have a TransactionProcessedEvent
that is created each time, the TransactionService processed a transaction
TransactionService
DB
Online Banking
Mobile Banking TransactionProcessedEvent
source = 18773 dest = 20770 amount = - 8.000 NTD
![Page 45: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/45.jpg)
Account BalanceLet’s assume we have a TransactionProcessedEvent
that is created each time, the TransactionService processed a transaction
TransactionService
DB
Online Banking
Mobile Banking TransactionProcessedEvent
source = 18773 dest = 20770 amount = -8.000 NTDTransactionProcessedEvent
source = 170805 dest = 18773 amount = +1.500 NTD
![Page 46: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/46.jpg)
Account BalanceThe balance depends on transactions.
Where can I find the current account balance?
• select balance from acc where accno=18773
• replay all events • use „empty“ / initial account • sum up all TransactionProcessedEvents
![Page 47: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/47.jpg)
Account Balance
Accountbalance = 0
![Page 48: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/48.jpg)
Account Balance
TPE (+120.000 NTD)
Accountbalance = 120.000
![Page 49: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/49.jpg)
Account Balance
TPE (+120.000 NTD)
Accountbalance = 118.500
TPE (- 1.500 NTD)
![Page 50: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/50.jpg)
Account Balance
TPE (+120.000 NTD)
Accountbalance = 110.500
TPE (- 1.500 NTD)
TPE (- 8.000 NTD)
![Page 51: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/51.jpg)
Account Balance
TPE (+120.000 NTD)
Accountbalance = 127.500
TPE (- 1.500 NTD)
TPE (- 8.000 NTD)
TPE (+ 17.000 NTD)
![Page 52: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/52.jpg)
Account Balance
TPE (+120.000 NTD)
Accountbalance = 677.500
TPE (- 1.500 NTD)
TPE (- 8.000 NTD)
TPE (+ 17.000 NTD)
TPE (+ 550.000 NTD)
![Page 53: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/53.jpg)
Account Balance
TPE (+120.000 NTD)
Accountbalance = 652.500
TPE (- 1.500 NTD)
TPE (- 8.000 NTD)
TPE (+ 17.000 NTD)
TPE (+ 550.000 NTD)
TPE (- 25.000 NTD)
![Page 54: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/54.jpg)
Account Balance
TransactionServiceAccountService
getTransactions()
![Page 55: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/55.jpg)
Account Balance
TransactionServiceAccountService
getTransactions()
TPE
![Page 56: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/56.jpg)
Account Balance
TransactionServiceAccountService
getTransactions()
TPE DB
ReadModel
![Page 57: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/57.jpg)
Account Balance
TransactionServiceAccountService
getTransactions()
TPE DB
ReadModel
no more synchronous dependency!
![Page 58: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/58.jpg)
!! Eventual Consistency !!
![Page 59: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/59.jpg)
!! Eventual Consistency !!
TransactionServiceAccountService
TPE DB
ReadModel
![Page 60: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/60.jpg)
!! Eventual Consistency !!
TransactionServiceAccountService
TPE DB
ReadModel t = 100 msec
![Page 61: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/61.jpg)
!! Eventual Consistency !!
TransactionServiceAccountService
TPE DB
ReadModel t = 100 msec
The transaction was already processed but the AccountService still uses the old balance
![Page 62: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/62.jpg)
!! Eventual Consistency !!
TransactionServiceAccountService
TPE DB
ReadModel t = 100 msec
The transaction was already processed but the AccountService still uses the old balance
Inconsistency! (but that’s how distribution works)
![Page 63: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/63.jpg)
Technical Realization• Domain Events are very similar to messages
• publish / subscribe & fire forget
![Page 64: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/64.jpg)
Technical Realization• Domain Events are very similar to messages
• publish / subscribe & fire forget
• Domain Events need a special semantic
• as a producer I want „fire & forget“
• as a consumer I want „exactly once“
![Page 65: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/65.jpg)
Technical Realization• Domain Events are very similar to messages
• publish / subscribe & fire forget
• Domain Events need a special semantic
• as a producer I want „fire & forget“
• as a consumer I want „exactly once“
• even if a consumer is down for some time
• even if a consumer is late to the game
![Page 66: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/66.jpg)
Technical Realization• Domain Events are very similar to messages
• publish / subscribe & fire forget
• Domain Events need a special semantic
• as a producer I want „fire & forget“
• as a consumer I want „exactly once“
• even if a consumer is down for some time
• even if a consumer is late to the game
multiple implementations available, e.g.:
Redis Persistent Queues
EventStore
Akka Persistence + MongoDB
![Page 67: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/67.jpg)
Time Traveling
![Page 68: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/68.jpg)
Time Traveling
AML Service
check limit
![Page 69: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/69.jpg)
Time Traveling
AML Service
TPE
check limit
![Page 70: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/70.jpg)
Time Traveling
AML Service
TPE
check limit suspicious
transactions
![Page 71: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/71.jpg)
Time Traveling
AML Service
TPE
check limit suspicious
transactions
Analytics Alerting
![Page 72: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/72.jpg)
Time TravelingAssume we will finish this service in two years.
How do we start it?
![Page 73: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/73.jpg)
Time TravelingAssume we will finish this service in two years.
How do we start it?
A - start up & wait for new events
![Page 74: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/74.jpg)
Time TravelingAssume we will finish this service in two years.
How do we start it?
A - start up & wait for new events
B - start up & process old events & wait for new events
![Page 75: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/75.jpg)
Time TravelingAssume we will finish this service in two years.
How do we start it?
A - start up & wait for new events
B - start up & process old events & wait for new events
Now, we can apply new software (or changes) to the past!
bug fixes, new features, new analytics, … agile!
![Page 76: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/76.jpg)
Time Traveling
AML Service
check limit suspicious
transactions
Analytics Alerting
TPE (+120.000 NTD)
TPE (- 1.500 NTD)
TPE (- 8.000 NTD)
TPE (+ 17.000 NTD)
TPE (+ 550.000 NTD)
TPE (- 25.000 NTD)
![Page 77: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/77.jpg)
Time Traveling
AML Service
check limit suspicious
transactions
Analytics Alerting
TPE (+120.000 NTD)
TPE (- 1.500 NTD)
TPE (- 8.000 NTD)
TPE (+ 17.000 NTD)
TPE (+ 550.000 NTD)
TPE (- 25.000 NTD)
TPE (+ 550.000 NTD)
![Page 78: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/78.jpg)
!! Race-Conditions !!We need „exactly once“!
![Page 79: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/79.jpg)
!! Race-Conditions !!We need „exactly once“!
AccountService
TPE
![Page 80: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/80.jpg)
!! Race-Conditions !!We need „exactly once“!
AccountService
TPE
![Page 81: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/81.jpg)
!! Race-Conditions !!We need „exactly once“!
AccountService
AccountServiceAccountService
Account Service Cluster
TPE
![Page 82: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/82.jpg)
!! Race-Conditions !!We need „exactly once“!
AccountService
AccountServiceAccountService
Account Service Cluster
TPE
![Page 83: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/83.jpg)
!! Race-Conditions !!We need „exactly once“!
AccountService
AccountServiceAccountService
Account Service Cluster
TPE
coor
dina
tor
![Page 84: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/84.jpg)
!! Race-Conditions !!We need „exactly once“!
AccountService
AccountServiceAccountService
Account Service Cluster
TPE
coor
dina
tor
multiple implementations available, e.g.:
Akka, …
![Page 85: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/85.jpg)
What is the result?
![Page 86: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/86.jpg)
What is the result?
Transactions
Customer
Account
Bank
AML
XYZ
![Page 87: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/87.jpg)
What is the result?
Transactions
Customer
Account
Bank
AML
XYZ
lots of dependencies high latency & low availability
![Page 88: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/88.jpg)
What is the result?
Transactions
Customer
Account
Bank
AML
XYZ
ReadModel
ReadModel
ReadModel
ReadModel
![Page 89: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/89.jpg)
What is the result?
Transactions
Customer
Account
Bank
AML
XYZ
ReadModel
ReadModel
ReadModel
ReadModel
lots of independent services low latency & high availability
![Page 90: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/90.jpg)
Sample Code
![Page 91: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/91.jpg)
Sample Code
http://bit.ly/1RYRY6p
https://github.com/senacor/CUB-codesamples-1/tree/es-akka-eventstore
![Page 92: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/92.jpg)
Event Sourcing …
… is not easy
But if you start thinking about this pattern, you will like how powerful it is
![Page 93: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/93.jpg)
Any Questions …… on Event Sourcing?
… on my project at Cathay United Bank?
Right now or later - just as you want.
![Page 94: Event Sourcing with Microservices](https://reader031.vdocument.in/reader031/viewer/2022030304/587a0b011a28ab01268b6a35/html5/thumbnails/94.jpg)
Any Questions …… on Event Sourcing?
… on my project at Cathay United Bank?
Right now or later - just as you want.