Let your domain events flow
KanDDDinsky, Oct 20th, 2017, Berlin, Germany
mail@bernd-ruecker.com
martin.schimak@plexiti.com
With thoughts from http://flowing.io
@berndruecker | @martinschimak
Bernd Rücker
Consultant & Dev. Advocate
10+ years workflow
Co-founder Camunda
http://bernd-ruecker.com/
Martin Schimak
Developer & Trainer, 10+ years
(de-)coding domain knowledge
DDDesign, TDD/BDD, EDA
http://plexiti.com/
http://flowing.io/
Simplified example:
dash button
Photo by 0xF2, available under Creative Commons BY-ND 2.0
license. https://www.flickr.com/photos/0xf2/29873149904/
Three steps…
Who is involved?
Checkout
Payment
Inventory
Shipment
Looking into events…
Checkout
Payment
Inventory
Shipment
Domain Events are facts
that happened in the pastGood
Fetched
Good
Stored
Read
Model
Write
Model
„The button blinks green
if we can ship the item
within 24 hours!“
Peer-to-peer event flows
Checkout
Payment
Inventory
Shipment
Payment
received
Order
placed
Goods
fetched
Peer-to-peer event flows
Checkout
Payment
Inventory
Shipment
Payment
received
Order
placed
Goods
fetched
Please fetch
the goods
before waiting
for payment
Some
customers can
pay via invoice
…
Some requirements don‘t fit anywhere… What are we missing?
Order
Checkout
Payment
Inventory
Shipment
Commands can decrease coupling
Order
Checkout
Payment
Inventory
Shipment
Order
placed
Retrieve
payment
Commands have an
intent about what needs
to happen in the future
Please fetch
the goods
before waiting
for payment
Some
customers can
pay via invoice
Payment
received
Retrieve
payment
Good API design respects responsibility boundaries
Order
Checkout
Payment
Inventory
Shipment
„A few smart god services
tell anemic CRUD services
what to do!”
Sam Newman
What is the payment
service responsible for?
Some things in life
take time
A customer can
update an expired
credit card within
two weeks before we
cancel his order
„
Payment
requires
persitent state
Order
Pass around state
as „routing slip“
Persist state with
Entity, Actor, …
State machine
How to
implement a
Process Manager?
DIY
DIY
State machine
Persistent thing
(Entity, Actor, …)
Routing
slip
CADENCE
Baker
State machines solve some hard developer problems
Monitoring &
Operations
Handling of time &
timeouts
Retry
Visibility &
Reporting
Versioning
Compensation
Message correlation &
deduplication
Performance &
scalability
Leaving the aggregate scope?
State machines solve some hard developer problems
Monitoring &
Operations
Handling of time &
timeouts
Retry
Visibility &
Reporting
Versioning
Compensation
Message correlation &
deduplication
Performance &
scalability
Bpmn.createProcess("order").executable()
//...
.sendTask().name("Retrieve payment").camundaClass(RetrievePayme
.receiveTask().name("Payment received").message("PaymentReceive
//...
{
"name": "retrieve_payment",
"tasks": [ {
"name": "Retrieve Payment",
"taskReferenceName": "payment",
"type": "SIMPLE",
...
Do you prefer coded or graphical DSLs?
* BPMN - ISO notation for modeling and
executing long-running processes and flows
Do you need a timeout?
Do you need a compensation? *
BPM?
Flows done right
Developer friendly Lightweight &
composable
BizDevOps
More complex flows - transparent and directly executable
Specifying and testing long-running behaviour
A visual test report for example #1 (Balance = 50, Amount = 70)
A visual test report for example #3 (Balance = 50, Amount = 30)
The binding strategy uses the step only when required
Living documentation for long-running behaviour
Explicit language help in tackling complex event flows
Ubiquitous
Language
Software
Experts
Domain
Experts
Explicit flows help sepatrate domain and infrastructure
Ports and Adapters
Application
Domain
Aggregates,
Domain Events,
Domain Services,
etc …
+ the flow
State
machine
Flows live inside the context boundaries
Example
InventoryPaymentOrder ShippingCheckout Monitor
https://github.com/flowing/flowing-retail/
Human
Tasks
Live hacking
Operational visibility in monitoring – possibly end-to-end
Mitigate tight
coupling Consider core
capabilities
Leverage state
machines
Decentralize
Thank you!
Code online:
https://github.com/flowing
Slides & Blog:
https://bernd-ruecker.com
https://plexiti.com
With thoughts from http://flowing.io
@berndruecker | @martinschimak
https://www.infoq.com
/articles/microservice-
event-choreographies
Images licensed from iStock
no attribution required
All icons licensed from Noun Project
no attribution required
Images licensed under Creative Commons license
Photo by 0xF2, available under
Creative Commons BY-ND 2.0 license.
https://www.flickr.com/photos/0xf2/2987
3149904/

KanDDDinsky: Let your domain events flow