SlideShare a Scribd company logo
From CRUD to messages
…a true story…
Alessandro Melchiori
@amelchiori
alessandro@codiceplastico.co
m
http://melkio.codiceplastico.co
m
…il contesto…
• Applicazione “finanziaria”
• Circa 70 (230) utenti
• 137.000+ (1.000.000+) aziende
• 420.000+ (4.500.000+) bilanci
• 38.000.000+ (650.000.000+) voci di
bilancio
• 16.000+ (85.000+) call/mese
• “Pluggato” a servizi di terze parti
• Picchi di lavoro “temporali”
PresentationLayer
Service/ApplicationLayer
DomainModel
Storage
From CRUD to messages: a true story
public interface ICompanyDossierService
{
void CloseCompanyFile(Guid id);
void SetInCharge(Guid id);
void SetAnalysisInCharge(Guid id);
IEnumerable<CompanyDossier> Search(Int16[] statuses, ...);
Guid Save(Guid companyFileId, String description, ...);
void DeleteAttachment(Guid id);
AttachmentStream GetAttachmentStream(Guid id);
...
}
From CRUD to messages: a true story
From CRUD to messages: a true story
ANY PROBLEM?
• Logica (mal) sparpagliata
• Contesti non definiti
• Modello “fragile” e poco propenso alle
evoluzioni
• Un unico modello per la lettura e per la
scrittura
• Prestazioni
• UI “generazionalista”
From CRUD to messages: a true story
An object model of the domain that
incorporates both behavior and data
[Martin Fowler - http://martinfowler.com/eaaCatalog/domainModel.html]
Use aggregates as unit of
consistency
across your domain model
Protect your model with clearly
defined bounded context
Eric Evans
Use aggregates as unit of
consistency
across your domain model
Protect your model with clearly
defined bounded context
Eric Evans
Use aggregates as unit of
consistency
across your domain model
Protect your model with clearly
defined bounded context
Eric Evans
A single model cannot be appropriate for
reporting, searching and transactional
behavior
Greg Young
PresentationLayer
ServiceLayer
DomainModel
Write storage
Read storage
State transition are an important part of our
problem space and should be modeled
within our domain
Greg Young, 2008
From CRUD to messages: a true story
{
"_id" : {
"BucketId" : "Documents/Type",
"StreamId" : "1",
"CommitSequence" : 1
}
"CheckpointNumber" : NumberLong(9460),
"CommitId" : LUUID("5aeae871-8a94-294a-88b1-b2487e5d88d6"),
"CommitStamp" : ISODate("2013-11-21T14:58:08.500Z"),
"Dispatched" : true,
"Events" : [ {
"StreamRevision" : 1,
"Payload" : {
”Code" : ”SITBNC",
”Name" : "Situazione bancaria”,
“Enabled” : true,
“Metadata” : []
}
}],
"Headers" : {
"who" : "guest",
"when" : "2013112115580858",
"when/ticks" : NumberLong(635206462884868984),
"correlation" : "230b5b33-a2ce-4f7e-aa4e-a885c3f05274”
}
}
It’s really become clear to me in the last
couple of years that we need a new building
block and that is the domain events
Eric Evans
It’s really become clear to me
in the last couple of years
that we need a new building block
and that is the domain events
Eric Evans
PresentationLayer
ServiceLayer
DomainModel
Write storage
Read storage
CONTACT CENTER FINANCE
Compute Ratings
Command
Appointment
Reserved
class ComputeRatingsCommandActivator :
IConsumer<AppointmentReserved>
{
public async Task Consume(
ConsumeContext<AppointmentReserved> context)
{
// COLLECT INFOS AND INITIALIZE THE COMMAND
var endpoint =
await context.GetSendEndpoint(“MyCommandEndpoint”);
endpoint.Send(command);
}
}
CONTACT CENTER
FINANCE
Compute Ratings
Command
Appointment
Reserved
CONSULTANT
Reserve Slot
Command
Appointment
Reserved
Appointment
Reserved
class MachineInstance : SagaStateMachineInstance
{
public Guid CorrelationId { get; private set; }
public State CurrentState { get; private set; }
public Boolean ConsultantCommandResponse { get; set; }
public Boolean FinanceCommandResponse { get; set; }
}
class StateMachine : MassTransitStateMachine<MachineInstance>
{
public StateMachine()
{
// MASSTRANSIT’S DSL TO DEFINE SAGA
}
public State Running { get; set; }
public Event<AppointmentActivated>
AppointmentActivated { get; private set; }
public Event<ConsultantCommandExecuted>
ConsultantCommandExecuted { get; private set; }
public Event<FinanceCommandExecuted>
FinanceCommandExecuted { get; private set; }
}
GOOD / BAD
CONTACT CENTER
FINANCE
Compute Ratings
Command
State Transition
Happened
CONSULTANT
Reserve Slot
Command
Resource
Changed
Resource
Changed
Resource
Changed
CONTACT CENTER
FINANCE
CONSULTANT
class ComputeRatingsCommandActivator :
IConsumer<AppointmentReserved>
{
public async Task Consume(
ConsumeContext<AppointmentReserved> context)
{
// COLLECT INFOS AND INITIALIZE THE COMMAND
var endpoint =
await context.GetSendEndpoint(“MyCommandEndpoint”);
endpoint.Send(command);
}
}
REST (HTTP)
TO THE RESCUE
class ComputeRatingsCommandActivator :
IConsumer<AppointmentReserved>
{
public async Task Consume(
ConsumeContext<AppointmentReserved> context)
{
// USE API (MICROSERVICE?) TO COLLECT INFOS
// AND INITIALIZE THE COMMAND
var endpoint =
await context.GetSendEndpoint(“MyCommandEndpoint”);
endpoint.Send(command);
}
}
> GET /api/appointments/13
< 200 Ok
< ETag: 686897696a7c876b7e
< Last-Modified: Thu, 05 Jul 2012 15:31:30
GMT
> GET /api/appointments/13
< 301 Moved permanently
< Location: http://...
DEPLOY?
SONO UNA CAGATA PAZZESCA!!!
I MICROSERVICES…
From CRUD to messages: a true story
WHEN?
Tackling complexity in the heart of software
WHEN?
Tackling complexity in the
heart of software
From CRUD to messages: a true story

More Related Content

PDF
Programming services-slides
PDF
“Create your own cryptocurrency in an hour” - Sandip Pandey
PPTX
RIA services exposing & consuming queries
PPTX
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
PDF
Programming clients-slides
PPTX
PDF
Introducing wcf-slides
PPTX
Programming services-slides
“Create your own cryptocurrency in an hour” - Sandip Pandey
RIA services exposing & consuming queries
[MongoDB.local Bengaluru 2018] Using Change Streams to Keep Up With Your Data
Programming clients-slides
Introducing wcf-slides

What's hot (15)

PPTX
Principais vulnerabilidades em Smart Contracts e como evitá-las
PPTX
Smart Contract programming 101 with Solidity #PizzaHackathon
PPT
Ken 20150306 心得分享
PPTX
Migrating our micro services from Java to Kotlin 2.0
PPTX
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
RTF
final
PPT
Linq e Ef
PPTX
Dex and Uniswap
PPTX
Blockchain and smart contracts day 2
PPTX
Solidity
PPTX
Smart Contracts with Solidity hands-on training session
PDF
How to use Twilio with Rails
PDF
Blockchain Coding Dojo - BlockchainHub Graz
PPTX
Oracles
PPTX
Solidity Security and Best Coding Practices
Principais vulnerabilidades em Smart Contracts e como evitá-las
Smart Contract programming 101 with Solidity #PizzaHackathon
Ken 20150306 心得分享
Migrating our micro services from Java to Kotlin 2.0
[MongoDB.local Bengaluru 2018] Just in Time Validation with JSON Schema
final
Linq e Ef
Dex and Uniswap
Blockchain and smart contracts day 2
Solidity
Smart Contracts with Solidity hands-on training session
How to use Twilio with Rails
Blockchain Coding Dojo - BlockchainHub Graz
Oracles
Solidity Security and Best Coding Practices
Ad

Similar to From CRUD to messages: a true story (20)

PPTX
Beyond DDD: uno sguardo a CQRS and event sourcing
PPTX
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
PDF
Mind Your Business. And Its Logic
PDF
Add Some DDD to Your ASP.NET MVC, OK?
PDF
Baby steps to Domain-Driven Design
PPTX
Brownfield Domain Driven Design
PDF
Asp net-mvc-3 tier
PPTX
Lets focus on business value
PPTX
Lets focus on business value
PPTX
Lets focus on business value
PPTX
Domain Driven Design(DDD) Presentation
PDF
Domain Driven Design
PPTX
Introduction to Event Sourcing and CQRS (IASA-IL)
PPT
Domain Driven Design (DDD)
PPTX
Command Query Responsibility Segregation
PPTX
Updated: Should you be using an Event Driven Architecture
PPTX
How ddd, cqrs and event sourcing constitute the architecture of the future
PPTX
Domain Driven Design
PDF
Introduction to Event Sourcing and CQRS
PPTX
Event Sourcing & CQRS: Down the rabbit hole
Beyond DDD: uno sguardo a CQRS and event sourcing
Seminar - Scalable Enterprise Application Development Using DDD and CQRS
Mind Your Business. And Its Logic
Add Some DDD to Your ASP.NET MVC, OK?
Baby steps to Domain-Driven Design
Brownfield Domain Driven Design
Asp net-mvc-3 tier
Lets focus on business value
Lets focus on business value
Lets focus on business value
Domain Driven Design(DDD) Presentation
Domain Driven Design
Introduction to Event Sourcing and CQRS (IASA-IL)
Domain Driven Design (DDD)
Command Query Responsibility Segregation
Updated: Should you be using an Event Driven Architecture
How ddd, cqrs and event sourcing constitute the architecture of the future
Domain Driven Design
Introduction to Event Sourcing and CQRS
Event Sourcing & CQRS: Down the rabbit hole
Ad

More from Alessandro Melchiori (20)

PDF
C# metaprogramming with source generator.pdf
PDF
Scale your (aks) cluster, luke!
PDF
A quick introduction to AKS
PDF
Developing reliable applications with .net core and AKS
PDF
VS Code tools for docker
PPTX
Developing reliable applications with .net core and AKS
PDF
How to search...better! (azure search)
PDF
AKS: k8s e azure
PDF
How to search...better!
PPTX
A quick tour around Azure Dev Spaces
PPTX
Azure functions: from a function to a whole application in 60 minutes
PPTX
Aks: k8s e azure
PDF
Monitoring docker: from zero to Azure
PPTX
Cooking Akka.net and Azure Service Fabric together
PPTX
Azure data platform overview
PPTX
ACR + ACS + VSTS: a complete ALM pipeline with docker and azure
PPTX
Docker & Azure
PDF
Docker and Azure
PPTX
Come ti "pusho" il web con WebSockets: da 0 a SignalR
PPTX
Docker &amp; azure
C# metaprogramming with source generator.pdf
Scale your (aks) cluster, luke!
A quick introduction to AKS
Developing reliable applications with .net core and AKS
VS Code tools for docker
Developing reliable applications with .net core and AKS
How to search...better! (azure search)
AKS: k8s e azure
How to search...better!
A quick tour around Azure Dev Spaces
Azure functions: from a function to a whole application in 60 minutes
Aks: k8s e azure
Monitoring docker: from zero to Azure
Cooking Akka.net and Azure Service Fabric together
Azure data platform overview
ACR + ACS + VSTS: a complete ALM pipeline with docker and azure
Docker & Azure
Docker and Azure
Come ti "pusho" il web con WebSockets: da 0 a SignalR
Docker &amp; azure

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
cuic standard and advanced reporting.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Spectroscopy.pptx food analysis technology
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Cloud computing and distributed systems.
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Encapsulation theory and applications.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Approach and Philosophy of On baking technology
Encapsulation_ Review paper, used for researhc scholars
Agricultural_Statistics_at_a_Glance_2022_0.pdf
MIND Revenue Release Quarter 2 2025 Press Release
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
cuic standard and advanced reporting.pdf
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectroscopy.pptx food analysis technology
The Rise and Fall of 3GPP – Time for a Sabbatical?
Cloud computing and distributed systems.
Digital-Transformation-Roadmap-for-Companies.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectral efficient network and resource selection model in 5G networks
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Encapsulation theory and applications.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
MYSQL Presentation for SQL database connectivity
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Approach and Philosophy of On baking technology

From CRUD to messages: a true story