Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current...
Transcript of Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current...
![Page 1: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/1.jpg)
Lost in transaction
[email protected] | @berndruecker
http://bernd-ruecker.com/
Co-Founder & Developer Advocate
![Page 2: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/2.jpg)
REST, SOAP,Cloud, Saas,
Microservices, SCS, FaaS, Serverless,
…
![Page 3: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/3.jpg)
Distributed systems
![Page 4: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/4.jpg)
Distributed systems
Challenges of asynchronicity
DistributedTransactions
Communication is complex
![Page 5: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/5.jpg)
Communication is complex
Challenge #1:
![Page 6: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/6.jpg)
SomeService
SomeService
SomeService
SomeService
SomeService
SomeService
SomeService
But keep it local! Be resilient.
Failure will happen. Accept it!
![Page 7: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/7.jpg)
Let‘s start with a simple example
CreditCard
Payment
REST
![Page 8: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/8.jpg)
Circuit Breaker
Photo by CITYEDV, available under Creative Commons CC0 1.0 license.
![Page 9: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/9.jpg)
Live hacking
Getting from https://github.com/flowing/flowing-retail/blob/master/payment-rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV1.java to V2
![Page 10: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/10.jpg)
Fail fastis important
![Page 11: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/11.jpg)
Fail fastis important
but not enough!
![Page 12: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/12.jpg)
Photo by Tookapic, available under Creative Commons CC0 1.0 license.
![Page 13: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/13.jpg)
„There was an errorwhile sending your
boarding pass“
![Page 14: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/14.jpg)
Check-in
3D-Barcode
Generator
Web-UI
Me
Output Mgmt
Current situation
Circuit breaker
![Page 15: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/15.jpg)
Check-in
3D-Barcode
Generator
Web-UI
Me
Output Mgmt
Current situation - the bad part
StatefulRetry
![Page 16: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/16.jpg)
„There was an errorwhile sending your
boarding pass“
![Page 17: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/17.jpg)
We are having some technicaldifficulties and cannot present you
your boarding pass right away.
But we do actively retry ourselves, so lean back, relax and we will send it
on time.
![Page 18: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/18.jpg)
Check-in
3D-Barcode
Generator
Web-UI
Me
Output Mgmt
StatefulRetry
Possible situation – much better!
The failurenever leavesthis scope!
![Page 19: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/19.jpg)
Persist thing(Entity, Actor, …)
State machine orworkflow engine
Typicalconcerns
DIY = effort, accidentalcomplexity
Complex, proprietary,
heavyweight, slow, developer adverse
Scheduling, Versioning, operating, visibility, scalability, …
Handling State
![Page 20: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/20.jpg)
State machines orworkflow engines
CADENCE
![Page 21: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/21.jpg)
Live hacking
Getting to https://github.com/flowing/flowing-retail/blob/master/payment-rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV3.java
![Page 22: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/22.jpg)
Check-in
3D-Barcode
Generator
Web-UI
Me
Output Mgmt
Workflows live inside service boundaries
![Page 23: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/23.jpg)
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
![Page 24: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/24.jpg)
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
![Page 25: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/25.jpg)
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
![Page 26: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/26.jpg)
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
![Page 27: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/27.jpg)
generateBoardingPass
HTTP 200 OK
HTTP 202 ACCEPTED
Check-in
A synchronous response is possible in thehappy case, otherwise it is switched to
asynchronous processing.
![Page 28: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/28.jpg)
Check-in
3D-Barcode
Generator
Web-UI
Me
Output Mgmt
„Eh – no!“
“The customers want synchronous responses!”
![Page 29: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/29.jpg)
Synchronous communicationis the crystal meth of
distributed programming
Todd Montgomery and Martin Thompson in “How did we end up here” at GOTO Chicago 2015
![Page 30: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/30.jpg)
Challenge #2:
Challenges of asynchronicity
![Page 31: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/31.jpg)
Check-in
3D-Barcode
Generator
Web-UI
Me
Output Mgmt
Asynchronous communication
You need tomonitor timeouts
![Page 32: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/32.jpg)
Check-in
3D-Barcode
Generator
Web-UI
Me
Output Mgmt
Remember…
The failurenever leavesthis scope!
![Page 33: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/33.jpg)
Workflow…
![Page 34: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/34.jpg)
Workflow…
![Page 35: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/35.jpg)
DuplicatesDuplicates
857621972_ded037d1db_b.jpg
Photo by oz dean, available under Creative Commons BY 2.0 license.
![Page 36: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/36.jpg)
It is impossible todifferentiate certain
failure scenarios.
This is also true forsynchronous
request/response!
Service Provider
Client
![Page 37: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/37.jpg)
has to implement
Timeout, Retryhas to implement
Idempotency
Client Service Provider
![Page 38: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/38.jpg)
We are processing your payment.
Do not leave this page.
And for god sake – do not reload!
It is a businessproblemanyway!
We are currently processing your request. Don‘t worry, it will happen safely –
even if you loose connection. Feel free to reload this page any time!
![Page 39: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/39.jpg)
Who has no problemsoperating a message bus?
Dead messages | No context | Inaccesible payload | Hard to redeliver | Home-grown message hospitals | …
![Page 40: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/40.jpg)
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
![Page 41: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/41.jpg)
Manigfold architecture options
https://blog.bernd-ruecker.com/architecture-options-to-run-a-workflow-engine-6c2419902d91
![Page 42: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/42.jpg)
Challenge #3:
DistributedTransactionsDistributed
Transactions
![Page 43: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/43.jpg)
Distributedsystems
![Page 44: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/44.jpg)
Business transactions (aka Saga pattern)
Compensation
![Page 45: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/45.jpg)
Eventual consistency
Temporarilyinconsistent state
But onlytemporarily!
![Page 46: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/46.jpg)
Live hacking
Getting to https://github.com/flowing/flowing-retail/blob/master/payment-rest/src/main/java/io/flowing/retail/payment/port/resthacks/PaymentRestHacksControllerV6.java
![Page 47: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/47.jpg)
has to implement
Timeout, Retry, Compensation
has to offer
Compensationhas to implement
Idempotency
Client Service Provider
![Page 48: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/48.jpg)
has to implement
Timeout, Retry, Compensation
has to offer
Compensationhas to implement
Idempotency
Client Service Provider
![Page 49: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/49.jpg)
Event-driven example also available
InventoryPaymentOrder ShippingCheckout Monitor
https://github.com/flowing/flowing-retail/
Human Tasks
H2 H2
![Page 50: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/50.jpg)
Workflows live inside service boundaries*
*in DDD: Bounded Contexts
![Page 51: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/51.jpg)
# Understand complexity of distributed systems# Know strategies and tools to handle ite.g. Circuit breaker (Hystrix)
Workflow engine for stateful retry, waiting, timeout and compensation (Camunda)
![Page 52: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/52.jpg)
Thank you!
![Page 53: Lost in transactionCircuit breaker. Check-in 3D-Barcode Generator Web-UI Me Output Mgmt Current situation - the bad part Stateful ... (aka Saga pattern) Compensation. Eventual consistency](https://reader035.fdocuments.us/reader035/viewer/2022062508/60418270dff2a332301cc678/html5/thumbnails/53.jpg)
Contact:[email protected]
@berndruecker
Slides:https://bernd-ruecker.com
Blog:https://blog.bernd-ruecker.com
Code online:https://github.com/flowing
https://www.infoq.com/articles/events-workflow-automation With thoughts from http://flowing.io
@berndruecker | @martinschimak