5. 5
Simple case – the
smart road
The road fare for each segment is
determined by the volume of
traffic in that segment in the
previous time window
Cameras in each segments
identifies the cars for: counting,
direct billing, tracking stolen cars
6. 6
Simple case – The
smart road
Identify vehicle
Calculate segment
rate
Bill driver
Detect payment
avoider
Detect stolen car
Event broker
No mutual consistency
required
7. 7
Simple case – The
smart road
Identify vehicle
Calculate segment
rate
Bill driver
Detect payment
avoider
Detect stolen car
Event broker
Identify Vehicle emits events with
segment and vehicle id. Calculate
Segment rate, Bill driver, detect
payment avoider and Detect stolen
car subscribe to it
8. 8
Simple case – The
smart road
Identify vehicle
Calculate segment
rate
Bill driver
Detect payment
avoider
Detect stolen car
Event broker
Calculate segment rate emits at
the end of every time window event
with new rates. Bill driver
subscribes to it.
9. 9
Simple case – The
smart road
Identify vehicle
Calculate segment
rate
Bill driver
Detect payment
avoider
Detect stolen car
Event broker
Detect stolen car and detect
payment avoider emit events that
the highway security subscribe to,
in order to stop vehicle.
10. 10
Constrained case –
Salary Increase
Salary determination process
results in salary increase.
There are two integrity
constraints:
1. Department total salaries and
other expenses cannot exceed
the budget
2.A manager salary must not be
more than the equivalent to 25
salaries of the lowest paid
subordinate (direct or indirect)
12. 12
Consistency in the
monolithic case
One transaction – either all commit
or all abort. Using ACP (Atomic
Commitment Protocol) such as: 2PC,
3PC
In the microservices case – breaks
the independence if applied
14. 14
Consistency 101
Stabilizers:
Restrict : Always abort inconsistencies
Nullify: Nullify problematic attributes
Repair Transaction: Typically minimal
repair that satisfies all constraints
Cascade: Repair existing data to satisfy
constraints
Forgive: Making it loosely consistent
15. 15
Back to the salary
increase story
Increase Salary
Handle Budget
Check manager
constraint
Event broker
Always use eventual consistency.
Consistency may be violated temporarily
16. 16
Back to the salary
increase story
Increase Salary
Handle Budget
Check manager
constraint
Event broker
The – commit or abort decision (or quasi
commit if supported) is emitted as event
and may trigger compensating
transaction in other microservice
17. 17
Back to the salary
increase story
Increase Salary
Handle Budget
Check manager
constraint
Event broker
Example: Budget violation occurred.
If RESTRICT applies - budget update
aborts; event emitted to broker,
published to Increase Salary and
triggers compensating transaction to
undo the salary increase
18. 18
Back to the salary
increase story
Increase Salary
Handle Budget
Check manager
constraint
Event broker
Example: Budget violation occurred.
If REPAIR TRANSACTION applies -
Budget update emits an event with
maximum salary increase allowed,
Increase Salary subscribes to it and
issues a compensating transaction to
modify the increase
19. 19
Back to the salary
increase story
Increase Salary
Handle Budget
Check manager
constraint
Event broker
Example: Budget violation occurred.
If Cascade applies -
Handle budget increases the budget in
the minimal amount that satisfies the
constraint
20. 20
Back to the salary
increase story
Increase Salary
Handle Budget
Check manager
constraint
Event broker
Example: Budget violation occurred.
If Forgive applies -
The consistency violation is ignored.
21. 21
Summary
Microservices and EDA co-exist
and complement each other
EDA serves as a vehicle to
communicate among microservices
without harming their isolation
EDA is Vital to cope with global
consistency requirements in a way that
each microservice is isolated, with no
global coordination mechanism or global
protocol.
22. 22
My long term work is aimed to take advantage of the
power of events to make a better world