This document discusses process orchestration and how it can increase agility without harming architecture. It begins by defining orchestration as command-driven communication and choreography as event-driven communication. It argues that while choreography allows for easy initial development, it can lead to technical debt over time by losing sight of larger business processes. Orchestration embraces asynchronicity and long-running processes to better model domain logic and responsibilities. This allows placing processes within service boundaries rather than having a few "god services". The document advocates balancing both orchestration and choreography based on responsibility and direction of coupling. It also suggests a center of excellence can help provide infrastructure while individual domains focus on solution delivery.
9. Why is it so tempting?
Service
A
Event Bus
A
B
Service
B
C
Service
C
D
E
F
Service
D
G
Service
…
Service
…
Service …
Service
…
Service …
Service …
Service
…
@berndruecker
10. Why is it so tempting?
Service
A
Event Bus
A
B
Service
B
C
Service
C
D
E
F
Service
D
G
Service
…
Service
…
Service …
Service
…
Service …
Service …
Service
…
Adding is easy!
You can „buy“ a shorter
initial time-to-value
by choreography.
It yields in technical debt.
@berndruecker
13. 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
14. 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
15. 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
16. Order
Fulfillment
Extract the domain logic around order fulfillment
Checkout
Payment
Inventory
Shipment
Payment
received
Order
placed
Retrieve
payment
@berndruecker
19. Definitions
Event = Something happened in the past. It is a fact.
Sender does not know who picks up the event.
Command = Sender wants s.th. to happen. It has an intent.
Recipient does not know who issued the command.
20. Order
It is not about the protocol!
Checkout
Payment
Inventory
Shipment
Order
placed
Retrieve
payment
It can still be messaging!
@berndruecker
21. Communication vs. Collaboration Style
Communication
Style
Synchronous
Blocking
Asynchronous
Non-Blocking
Collaboration
Style
Command-Driven Event-Driven
Example REST
Messaging
(Queues)
Messaging
(Topics)
Feedback Loop
HTTP
Response
Response
Message
-
Pizza Ordering via Phone Call E-Mail Twitter
This is not the
same!
See https://www.slideshare.net/BerndRuecker/jcon-2021-loosely-or-lousily-coupled
28. Using a workflow engine
Workflow Engine
Scheduler
Durable State
Glue Code Whatever you
need…
Workflow Definition
Workflow Engine:
Is stateful
Can wait
Can retry
Can escalate
Can compensate
Provides visibility
29. Now it is easy to change the orchestration logic
@berndruecker
35. Commands in disguise
The Customer Needs To Be
Sent A Message To Confirm
Address Change
Event
Send
Message
Wording of
Sender
Wording of
recipient
36. Checkout Order Payment
Event-driven:
Decision to couple is on the receiving side
Command-driven
Decision to couple is on the sending side
Direction of dependency
Retrieve
Payment
Order
placed
Payment
received
Direction of dependency
38. Types of Coupling
Type of coupling Description Example Recommendation
Implementation Coupling Service knows internals of
other services
Joined database Avoid
39. Types of Coupling
Type of coupling Description Example Recommendation
Implementation Coupling Service knows internals of
other services
Joined database Avoid
40. Types of Coupling
Type of coupling Description Example Recommendation
Implementation Coupling Service knows internals of
other services
Joined database Avoid
Temporal Coupling Service depends on
availability of other
services
Synchronous blocking
communication
Reduce or manage
41. Types of Coupling
Type of coupling Description Example Recommendation
Implementation Coupling Service knows internals of
other services
Joined database Avoid
Temporal Coupling Service depends on
availability of other
services
Synchronous blocking
communication
Reduce or manage
This is influenced with the communication
or collaboration style
Can be also reduced by other means
than asynchronous messaging!
42. Types of Coupling
Type of coupling Description Example Recommendation
Implementation Coupling Service knows internals of
other services
Joined database Avoid
Temporal Coupling Service depends on
availability of other
services
Synchronous blocking
communication
Reduce or manage
Deployment Coupling Multiple services can only
be deployed together
Release train Typically avoid, but
depends
43. Types of Coupling
Type of coupling Description Example Recommendation
Implementation Coupling Service knows internals of
other services
Joined database Avoid
Temporal Coupling Service depends on
availability of other
services
Synchronous blocking
communication
Reduce or manage
Deployment Coupling Multiple services can only
be deployed together
Release train Typically avoid, but
depends
44. Types of Coupling
Type of coupling Description Example Recommendation
Implementation Coupling Service knows internals of
other services
Joined database Avoid
Temporal Coupling Service depends on
availability of other
services
Synchronous blocking
communication
Reduce or manage
Deployment Coupling Multiple services can only
be deployed together
Release train Typically avoid, but
depends
Domain Coupling Business capabilities
require multiple services
Order fulfillment requires
payment, inventory and
shipping
Unavoidable unless you
change business
requirements or service
boundaries
45. Types of Coupling
Type of coupling Description Example Recommendation
Implementation Coupling Service knows internals of
other services
Joined database Avoid
Temporal Coupling Service depends on
availability of other
services
Synchronous blocking
communication
Reduce or manage
Deployment Coupling Multiple services can only
be deployed together
Release train Typically avoid, but
depends
Domain Coupling Business capabilities
require multiple services
Order fulfillment requires
payment, inventory and
shipping
Unavoidable unless you
change business
requirements or service
boundaries
54. Example
Order
Fulfillment
Payment
If the credit
card was
rejected, the
customer can
provide new
details
Credit
Card
Retrieve
Payment
Rejected
Rejected
@berndruecker
A few
smart god services
tell
anemic CRUD services
what to do
Sam Newmann
55. Payment
failed
Who is responsible to deal with problems?
Order
Fulfillment
Payment
If the credit
card was
rejected, the
customer can
provide new
details
Credit
Card
Retrieve
Payment
Rejected
Payment
received
@berndruecker
59. Business Unit
or Domain
Business Unit
or Domain
Business Unit
or Domain
Process Automation
Center or Excellence
Solution
Delivery
Solution
Delivery
Solution
Delivery
Solution
Delivery
Solution
Delivery
enable Provide custom
connectors
Provide process
orcherstration
as a service
…
65. Photo by born1945, available under Creative Commons BY 2.0 license.
Domain A
Domain B
66. # Orchestration != central
# Choreography != decoupled
# Orchestration = Command-driven
# Choreography = Event-driven
# You need to balance both!
# It is about responsibility and the direction of coupling
# You need long running capabilities to design good boundaries
# Some central capability for providing infrastructure helps
@berndruecker