SlideShare a Scribd company logo
Building
Autonomous
Services
Matthias Noback
@matthiasnoback
http://github.com/matthiasnoback/

building-autonomous-services-workshop/
Install this project
Ooph!
Building Autonomous Services
About the domain
We have a much simplified warehousing domain with
several services:
1. Catalog: Managing products in a catalog.
2. Purchasing: Receiving products that were previously
purchased from a supplier.
3. Sales: selling to a customer products that we have in
stock.
What are we doing here?
Building autonomous services
Why do you want to use
services?
Why do they have to be
autonomous?
The problem is
designing for
autonomy
Building Autonomous Services
Building Autonomous Services
Building Autonomous Services
Building Autonomous Services
What about queries?
Building Autonomous Services
Building Autonomous Services
"What's the current
state of something-
something?"
The current state is the
result of all past events
Building Autonomous Services
Building Autonomous Services
Building Autonomous Services
Building Autonomous Services
Building Autonomous Services
Building Autonomous Services
Solving the query issue
1. Services publish their events.
2. Other services subscribe to these events and update their
own state accordingly.
3. They can build up any projection they like. This gives
them the answers they need, without even asking.
tail -n 1 -f
Demo
Assignments
• assignments/d+.md
• Take a look at tips-and-tricks.md
Assignment 01
Create a projection to make Purchase autonomous
Catalog Purchase
Sales
product created
Products
Products
Questions
How much data should you send with an event?
Questions
When should you dispatch the events?
Questions
Since you may have created a product before you started
publishing events about it, your database may contain
products, which are not in the stream. Hence, they are not
stored as local products in the *Purchase* context. What
would be needed to fix these inconsistencies? Think of/
discuss several strategies.
Questions
What happens if you have a bug in your consumer and it
doesn't process an incoming event correctly? Take a look at
the code and comments of `Stream::consume()` and find out
what its built-in mechanism is to counter this situation.
What does this mean for the implementation of the
consumer?
Prologue to assignment
02
Process manager
A consumer with side-effects
Process manager
• Consumes every message (event) from the stream only
once
• Responds with any of the following:
• Publishing a command
• Producing a new event
• Updating the status of a long-running process
Assignment 02
Create a process manager to make Stock autonomous
Purchase
Sales
goods received
goods delivered
Stock Balance
Questions
Events potentially increase coupling between services. An
event exposes details about the internal domain model of a
service. When consuming events, services gather
knowledge about each other's internals. This can lead to
something known as a "distributed monolith". There may be
runtime autonomy, but there will be lots of violations of
D.R.Y. (the *knowledge* aspect of it). Come up with a way to
prevent this.
Questions
*Stock* currently doesn't store the names of the products,
would it be better if it would? Think of some reasons for or
against it.
Prologue to assignment
03
Contexts
• Transition of meaning: in one context "goods received", in
the other context "stock increased".
• Simplification of the message (same example), but also: "user
added" as a summary of "user created", "user activated",
"email confirmed", etc.
Upon receiving an event...
• Produce a new event and add it to the stream.
• This is a side-effect (i.e. it has effects noticeable on the
outside of the service).
• A "projector consumer" can rebuild its projection again and
again, because it's internal to the service.
Assignment 03
Create a process manager to convert events
Stock stock level changed
Catalog product created
Dashboard
Products
+ stock levels
Questions
Couldn't we just use a "stock level changed" event?
What about "stock level increased/decreased" events with a
"current stock level" value?
Assignment 04
Auto-create a purchase order using an HTTP POST
request
Questions
Should we create a purchase order for the entire quantity of
the sales order, or just the difference between the ordered
quantity and the current stock level?
Questions
What have we done?! We have created a direct, runtime
dependency between *Sales* and *Purchase*... Not very
smart, since the request for making a sales order might fail,
even though the reason for this failure is a problem in
*Purchase*. Can you think of a solution for the lack in
autonomy?
Questions
Consider the following situation: when we check for the
current stock level of a product, immediately after that the
product gets delivered to someone else. So when we try to
deliver our sales order, it won't be possible anymore (and
we should have added it to the purchase order after all!).
What could we do about this?
Prologue to assignment
05
The Reservation Pattern
• In a system with concurrency, there's always the chance
you're looking at stale data.
• If you sell x items to a customer, they could be sold at the
same time to another customer.
• So: you first need to make a reservation.
Stock reservation
• New sales order? Make a stock reservation.
• When it's okay, commit and deliver the order.
• When it's not okay, respond to it: make a purchase order.
Assignment 05
The Reservation Pattern
Sales
sales order
created
make stock
reservation
Stock
reservation
accepted
deliver sales
order
Sales Process Manager
Questions
Isn't it bad to make HTTP POST calls?
Assignment 06
Taking actions when the stock reservation gets rejected
Sales
sales order
created
make stock
reservation
Stock
reservation
accepted
deliver sales
order
Sales Process Manager
reservation
rejected
create
purchase orderPurchase
goods received
make stock
reservation
Assignment 07
Turn OrderStatus into a state machine
Assignment 08
Gain visual insight in the order status

More Related Content

PDF
Hexagonal Symfony - SymfonyCon Amsterdam 2019
PDF
Advanced web application architecture - Talk
PDF
Advanced web application architecture Way2Web
PDF
Service abstractions - Part 1: Queries
PDF
Advanced web application architecture - PHP Barcelona
PDF
A testing strategy for hexagonal applications
PDF
Layers, ports and adapters
PDF
Advanced Application Architecture Symfony Live Berlin 2018
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Advanced web application architecture - Talk
Advanced web application architecture Way2Web
Service abstractions - Part 1: Queries
Advanced web application architecture - PHP Barcelona
A testing strategy for hexagonal applications
Layers, ports and adapters
Advanced Application Architecture Symfony Live Berlin 2018

What's hot (20)

PPTX
ReactJS - Re-rendering pages in the age of the mutable DOM
PDF
Advanced application architecture
PDF
React + Mobile
ODP
WebNano - Ideas for Web Frameworks
PDF
Introduce Flux & react in practices (KKBOX)
PDF
Breaking the Server-Client Divide with Node.js and React
PDF
React Introduction
PDF
Messaging
PPTX
"Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
PDF
Services, dependencies, and you
PDF
Microservices - Please, don't
PDF
Akka - Developing SEDA Based Applications
PDF
Meteor Revolution: From DDP to Blaze Reactive Rendering
PDF
Introduction to React, Flux, and Isomorphic Apps
PDF
Performant Django - Ara Anjargolian
PPTX
Ajax Technology
PDF
Andrii Sliusar "Module Architecture of React-Redux Applications"
PPTX
Do you queue (updated)
PPTX
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
ReactJS - Re-rendering pages in the age of the mutable DOM
Advanced application architecture
React + Mobile
WebNano - Ideas for Web Frameworks
Introduce Flux & react in practices (KKBOX)
Breaking the Server-Client Divide with Node.js and React
React Introduction
Messaging
"Fast / Resilient / .NET – What to Choose?" Serhiy Kalinets
Services, dependencies, and you
Microservices - Please, don't
Akka - Developing SEDA Based Applications
Meteor Revolution: From DDP to Blaze Reactive Rendering
Introduction to React, Flux, and Isomorphic Apps
Performant Django - Ara Anjargolian
Ajax Technology
Andrii Sliusar "Module Architecture of React-Redux Applications"
Do you queue (updated)
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
Ad

Similar to Building Autonomous Services (20)

PPTX
Patterns of Distributed Application Design
PDF
Patterns of Distributed Application Design
DOCX
RabbitMQ in Microservice Architecture.docx
PDF
Events and microservices
PPTX
Microservices with .Net - NDC Sydney, 2016
PPTX
Event Driven Microservices architecture
PPTX
Autonomous microservices for a Financial System
PPTX
Microservices Decomposition Patterns.v1.0.20191009
PPTX
Microservices Decomposition Patterns
PPTX
Architecting Microservices in .Net
PPTX
Scaling Your Architecture with Services and Events
PDF
Design Microservice Architectures the Right Way
PDF
Data Microservices with Spring Cloud
PDF
Microservices patterns
PPTX
Introduction to Microservices Patterns
PPTX
Introduction to Microservices Patterns
KEY
Event Driven Architecture
PPTX
Let's talk about... Microservices
PPTX
Lets focus on business value
PPTX
Lets focus on business value
Patterns of Distributed Application Design
Patterns of Distributed Application Design
RabbitMQ in Microservice Architecture.docx
Events and microservices
Microservices with .Net - NDC Sydney, 2016
Event Driven Microservices architecture
Autonomous microservices for a Financial System
Microservices Decomposition Patterns.v1.0.20191009
Microservices Decomposition Patterns
Architecting Microservices in .Net
Scaling Your Architecture with Services and Events
Design Microservice Architectures the Right Way
Data Microservices with Spring Cloud
Microservices patterns
Introduction to Microservices Patterns
Introduction to Microservices Patterns
Event Driven Architecture
Let's talk about... Microservices
Lets focus on business value
Lets focus on business value
Ad

More from Matthias Noback (20)

PDF
Rector fireside chat - PHPMiNDS meetup
PDF
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
PDF
Beyond design principles and patterns (muCon 2019 edition)
PDF
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
PDF
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
PDF
Beyond Design Principles and Patterns
PDF
Designing for Autonomy
PDF
Docker workshop
PDF
Docker swarm workshop
PDF
Docker compose workshop
PDF
Building autonomous services
PDF
Designing for autonomy
PDF
Continously delivering containerized microservices
PDF
Apprendre le français
PDF
Living Documentation (presentation)
PDF
TDD - A Reminder of the Principles
PDF
Docker workshop
PDF
CQRS & Event Sourcing
PDF
Advanced Application Architecture (workshop slides)
PDF
Programming with Cmdr. Chris Hadfield
Rector fireside chat - PHPMiNDS meetup
DPC 2019, Amsterdam: Beyond design patterns and principles - writing good OO ...
Beyond design principles and patterns (muCon 2019 edition)
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Brutal refactoring, lying code, the Churn, and other emotional stories from L...
Beyond Design Principles and Patterns
Designing for Autonomy
Docker workshop
Docker swarm workshop
Docker compose workshop
Building autonomous services
Designing for autonomy
Continously delivering containerized microservices
Apprendre le français
Living Documentation (presentation)
TDD - A Reminder of the Principles
Docker workshop
CQRS & Event Sourcing
Advanced Application Architecture (workshop slides)
Programming with Cmdr. Chris Hadfield

Recently uploaded (20)

PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
System and Network Administraation Chapter 3
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
top salesforce developer skills in 2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Nekopoi APK 2025 free lastest update
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms II-SECS-1021-03
Understanding Forklifts - TECH EHS Solution
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PTS Company Brochure 2025 (1).pdf.......
System and Network Administraation Chapter 3
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Operating system designcfffgfgggggggvggggggggg
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
top salesforce developer skills in 2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Nekopoi APK 2025 free lastest update
Softaken Excel to vCard Converter Software.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Odoo POS Development Services by CandidRoot Solutions
L1 - Introduction to python Backend.pptx

Building Autonomous Services