Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
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+)...
PresentationLayer
Service/ApplicationLayer
DomainModel
Storage
public interface ICompanyDossierService
{
void CloseCompanyFile(Guid id);
void SetInCharge(Guid id);
void SetAnalysisInCha...
ANY PROBLEM?
• Logica (mal) sparpagliata
• Contesti non definiti
• Modello “fragile” e poco propenso alle
evoluzioni
• Un unico modello...
An object model of the domain that
incorporates both behavior and data
[Martin Fowler - http://martinfowler.com/eaaCatalog...
Use aggregates as unit of
consistency
across your domain model
Protect your model with clearly
defined bounded context
Eri...
Use aggregates as unit of
consistency
across your domain model
Protect your model with clearly
defined bounded context
Eri...
Use aggregates as unit of
consistency
across your domain model
Protect your model with clearly
defined bounded context
Eri...
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
{
"_id" : {
"BucketId" : "Documents/Type",
"StreamId" : "1",
"CommitSequence" : 1
}
"CheckpointNumber" : NumberLong(9460),...
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...
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...
PresentationLayer
ServiceLayer
DomainModel
Write storage
Read storage
CONTACT CENTER FINANCE
Compute Ratings
Command
Appointment
Reserved
class ComputeRatingsCommandActivator :
IConsumer<AppointmentReserved>
{
public async Task Consume(
ConsumeContext<Appointm...
CONTACT CENTER
FINANCE
Compute Ratings
Command
Appointment
Reserved
CONSULTANT
Reserve Slot
Command
Appointment
Reserved
A...
class MachineInstance : SagaStateMachineInstance
{
public Guid CorrelationId { get; private set; }
public State CurrentSta...
GOOD / BAD
CONTACT CENTER
FINANCE
Compute Ratings
Command
State Transition
Happened
CONSULTANT
Reserve Slot
Command
Resource
Changed
...
CONTACT CENTER
FINANCE
CONSULTANT
class ComputeRatingsCommandActivator :
IConsumer<AppointmentReserved>
{
public async Task Consume(
ConsumeContext<Appointm...
REST (HTTP)
TO THE RESCUE
class ComputeRatingsCommandActivator :
IConsumer<AppointmentReserved>
{
public async Task Consume(
ConsumeContext<Appointm...
> 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…
WHEN?
Tackling complexity in the heart of software
WHEN?
Tackling complexity in the
heart of software
From CRUD to messages: a true story
From CRUD to messages: a true story
From CRUD to messages: a true story
From CRUD to messages: a true story
From CRUD to messages: a true story
From CRUD to messages: a true story
From CRUD to messages: a true story
Prochain SlideShare
Chargement dans…5
×

From CRUD to messages: a true story

904 vues

Publié le

A true story about how we evolved our architecture from a monolithic approach to a distributed system

Publié dans : Technologie
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici
  • DOWNLOAD FULL BOOKS INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL PDF EBOOK here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL EPUB Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... 1.DOWNLOAD FULL doc Ebook here { https://tinyurl.com/y8nn3gmc } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Répondre 
    Voulez-vous vraiment ?  Oui  Non
    Votre message apparaîtra ici

From CRUD to messages: a true story

  1. 1. From CRUD to messages …a true story…
  2. 2. Alessandro Melchiori @amelchiori alessandro@codiceplastico.co m http://melkio.codiceplastico.co m
  3. 3. …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”
  4. 4. PresentationLayer Service/ApplicationLayer DomainModel Storage
  5. 5. 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); ... }
  6. 6. ANY PROBLEM?
  7. 7. • 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”
  8. 8. An object model of the domain that incorporates both behavior and data [Martin Fowler - http://martinfowler.com/eaaCatalog/domainModel.html]
  9. 9. Use aggregates as unit of consistency across your domain model Protect your model with clearly defined bounded context Eric Evans
  10. 10. Use aggregates as unit of consistency across your domain model Protect your model with clearly defined bounded context Eric Evans
  11. 11. Use aggregates as unit of consistency across your domain model Protect your model with clearly defined bounded context Eric Evans
  12. 12. A single model cannot be appropriate for reporting, searching and transactional behavior Greg Young
  13. 13. PresentationLayer ServiceLayer DomainModel Write storage Read storage
  14. 14. State transition are an important part of our problem space and should be modeled within our domain Greg Young, 2008
  15. 15. { "_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” } }
  16. 16. 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
  17. 17. 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
  18. 18. PresentationLayer ServiceLayer DomainModel Write storage Read storage
  19. 19. CONTACT CENTER FINANCE Compute Ratings Command Appointment Reserved
  20. 20. 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); } }
  21. 21. CONTACT CENTER FINANCE Compute Ratings Command Appointment Reserved CONSULTANT Reserve Slot Command Appointment Reserved Appointment Reserved
  22. 22. 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; } }
  23. 23. GOOD / BAD
  24. 24. CONTACT CENTER FINANCE Compute Ratings Command State Transition Happened CONSULTANT Reserve Slot Command Resource Changed Resource Changed Resource Changed
  25. 25. CONTACT CENTER FINANCE CONSULTANT
  26. 26. 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); } }
  27. 27. REST (HTTP) TO THE RESCUE
  28. 28. 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); } }
  29. 29. > GET /api/appointments/13 < 200 Ok < ETag: 686897696a7c876b7e < Last-Modified: Thu, 05 Jul 2012 15:31:30 GMT
  30. 30. > GET /api/appointments/13 < 301 Moved permanently < Location: http://...
  31. 31. DEPLOY?
  32. 32. SONO UNA CAGATA PAZZESCA!!! I MICROSERVICES…
  33. 33. WHEN? Tackling complexity in the heart of software
  34. 34. WHEN? Tackling complexity in the heart of software

×