orchestration of microservices - java forum stuttgart · orchestration of microservices...
TRANSCRIPT
Orchestration of Microservices
With thoughts from http://flowing.io@berndruecker | @martinschimak
AT&T
Microservoices?
https://www.flickr.com/photos/12567713@N00/310639290
Microservices
• Independent components
• Independent deployments
• Decoupling between components
• Dedicated teams to fight conways law
• Autonomy of technology decisions
• Avoid horizontal team boundaries
• New DevOps paradigms
Microservice
Microservice
Microservice
Monolith
A
B
C
A
B
C
Increasingcomplexityof relation-
ships
Event-Driven Microservices
Microservice Microservice
A B
Event
event namepayload
no receipient
Event-Driven Microservices
Microservice Microservice
A B
Event
Does not know
about B
Does not know
about A
Isn‘t that SOA?
Service Service
A B
ESB
It is not SOA
Service Service
A B
ESB
„smart endpoints and dumb pipes”
Disclaimer: I do not advertise event-drivenmicroservices as silver bullet!
Only use it when appropriate.Handle with care!
Distributed systems
You need some safe harbors and strategies to sail the wild ocean
Microservices Event Driven & Reactive Domain Driven Design
Let‘s do an example!
Assume you wantto build a Dash button.
pay receive
shipment
place
order
I want to have
one item!
I am happy!
Business Capabilities
BoundedContexts= Microservices
Order placed
Shop Payment Shipping
BusinessOutputs / Domain Events
Inventory
Payment received
Goodsfetched
Goodsshipped
Collaboration using an eventflow
Order placed
Payment received
Goodsfetched
Goodsshipped
InventoryPayment ShippingShop
Great!
Great?
Let‘s zoom in the payment context
PaymentOrder placed
Payment received
Let‘s zoom in the payment context
PaymentOrder placed
Payment received
The payment contexthas to listen to
„order placed“ event
De-coupling?
Payment
Orderplaced
Servicefullfilled
…
Whenever a new client requirespayment, the payment contexthas to be touched
The payment context has to knowall possible events that trigger a payment
Subscriptionconfirmed
Event command transformation
PaymentRetrievepayment
Orderplaced Transformation
CommandSomething has to happenin the future1 recipient
EventSomething has happendin the past0..n recipients
Order context
PaymentRetrievepayment
Orderplaced Order
Event vs. command
PaymentRetrievepayment
Orderplaced Order
decide where todo the coupling
Business Capabilities
Order placed
Shop Payment ShippingInventory
Payment received
Goodsfetched
Goodsshipped
Order
Order completed
Retrievepayment
Fetchgoods
Shipgoods
Quality Criteria: Changability
VIP customers can order with invoice (and pay later)
Changability with pure event-chain
Order placed
Payment received
Goodsfetched
Goodsshipped
InventoryPayment ShippingShop
If VIP customer
If not VIP customer
Order billed
Billing
If VIP customer
VIP customers can order with invoice (and pay later)
Changability with Event Command Transformation
Order placed
Shop Payment ShippingInventory
Payment received
Goodsfetched
Goodsshipped
Order
Order completed
VIP customers can order with invoice (and pay later)
Change howto issue
commands
Quick demo
http://github.com/flowing/
Now back to real-life
Some things in live might be slow
Payment
Retrievepayment
Orderplaced Order
Paymentretrieved
Long running flowsrequire persistent state
How to implement?
State in entity
More alternatvies in my blog: https://blog.bernd-ruecker.com/how-to-implement-long-running-flows-sagas-business-processes-or-similar-3c870a1b95a8
The 7 sins of workflow
3
4
6
5
7
http://blog.bernd-ruecker.com/
No state machine
Homegrownstate machine
Think about subsequent requirements
Monitoring & Operations
Visibility
VersioningTime &
Timeouts
Domain Language
Performance & Scaling
Process Manager
• Do event command transformation
• Handle state for long running flows
State machine http://camunda.org/
Logic remains in normal code
Tools provide persistent state, visibility and much more
+
On top: visbility
PaymentRetrievepayment
Orderplaced Order
Martin Fowler
Event notification is nice because it implies a low level of coupling, and is pretty simple to set up. It can become problematic, however, if there really is a logical flow that runs over various event notifications. The problem is that it can be hard to see such a flow as it's not explicit in any program text. Often the only way to figure out this flow is from monitoring a live system. This can make it hard to debug and modify such a flow. The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years
https://martinfowler.com/articles/201701-event-driven.html
Smells like „BPM“?
The 7 sins of workflow
Homegrownengine
BPM monolith
No engine Wrong engine Wrong usage
http://blog.bernd-ruecker.com/
4 5
7
3
The end-to-end process?
Don‘t do a „BPM monolith“ when using Microservices!
Order Feedback
InventoryPayment
Pa
yme
nt
Local flows in the bounded contextsO
rde
r
Multiple engines
Payment
Order
engine
engine
…
Inventory
Shipping
…
engine
The 7 sins of workflow
Zero-code suites
Homegrownengine
No engine Wrong engine Wrong usage
4 5
7
http://blog.bernd-ruecker.com/
BPM monolith
Death by properties panel
Script:
Please enter your complex code here. (Without IDE support of course!)
Bernd Rücker
Consultant & Evangelist10+ years workflow
http://bernd-ruecker.com/[email protected]
Co-founder Camundahttp://camunda.org/
Define flows programatically or graphically
Productive development and testing
Developer friendly
Big challenges for developers ahead!
Error and timeout handling
Handling complex scenarios
Demo
http://github.com/flowing/
Demo architecture
InventoryPaymentOrder Shipping
H2
Shop Monitor
Camunda Webapp
on Tomcat
for demo in single Java VM for simplicity
https://github.com/flowing/flowing-retail/
Lightweight state machines orworkflow engines are not evil!
They do help you solving some reallyhard coding problems.
These problems become more and more frequent every day.
https://www.infoq.com/articles/microservice-event-choreographies
Code online:https://github.com/flowing
Slides online:http://bernd-ruecker.com
Feedback:http://bernd-ruecker.com/feedback
With thoughts from http://flowing.io@berndruecker | @martinschimak
Thank you!