SlideShare una empresa de Scribd logo
1 de 32
EventSourcing applied
Rickard Öberg, Jayway

Date
Agenda


✤   Domänmodeller och data

✤   Vad är EventSourcing

✤   Kodexempel

✤   Användning av EventSourcing
Domänmodeller och data
Snapshots
  ORM
Klient




         Snapshots
           ORM
Klient




Servicefacade




                Snapshots
                  ORM
Klient




Servicefacade




                Snapshots
                  ORM
Klient




Servicefacade




Domänmodell



                Snapshots
                  ORM
Klient




Servicefacade




Domänmodell



                Snapshots
                  ORM
Klient




Servicefacade




Domänmodell



                Snapshots
Datalagring
                  ORM
Klient




Servicefacade




Domänmodell



                Snapshots
Datalagring
                  ORM
3-i-1


✤   Tre typer av data:

    ✤   Flaggor och status

    ✤   Fritext

    ✤   Rapportstöd
Ändring av projektionen?


✤   “Spara vem som gjorde vad och när”

✤   “Ändra riktning på associationen”

✤   “Lägg till beräkning”

✤   “Fritextsökning!”
Vad är EventSourcing
Klient




              Servicefacade


Domänmodell
              Kommandon


                 Events




              Eventlagring
Kodexempel
void setDescription(String newDescription)
{
  description().set(newDescription);
}
void changeDescription(String newDescription)
{
  if (... description is ok ...)
     changedDescription(newDescription);
}

@DomainEvent
void changedDescription(String newDescription)
{
  description().set(newDescription);
}
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Change
description" ));
uow.metaInfo().set( administratorPrincipal );

TestEntity entity = uow.newEntity( TestEntity.class );
entity.changedDescription( "New description" );
uow.complete();
public interface UnitOfWorkDomainEventsValue
        extends ValueComposite
{
    // Version of the application that created these events
    Property<String> version();

    // Usecase name
    Property<String> usecase();

    // When the event occurred
    Property<Long> timestamp();

    // Who performed the event. Taken from CurrentUser service.
    @Optional
    Property<String> user();

    // List of events for this transaction
    @UseDefaults
    Property<List<DomainEventValue>> events();
}
public interface DomainEventValue
        extends ValueComposite
{
    // Type of the entity being invoked
    Property<String> entityType();

    // Id of the entity that generated the event
    Property<String> entityId();

    // Name of method/event
    Property<String> name();

    // Method parameters as JSON
    Property<String> parameters();
}
EventSource source = ...

source.events( 0, Long.MAX_VALUE ).transferTo( Transforms.map( new
Function<UnitOfWorkDomainEventsValue, String>()
{
    public String map( UnitOfWorkDomainEventsValue unitOfWorkDomainEventsValue )
    {
        return unitOfWorkDomainEventsValue.toJSON();
    }
}, Outputs.systemOut()));
{"events":[{"entityId":"1da7e923-f9b2-4588-9967-
cb29e18098be-0","entityType":"org.qi4j.library.eventsourcing.domain.DomainEventTest
$TestEntity","name":"changedDescription","parameters":"{"param0":"New description
"}"}],"timestamp":1295860519645,"usecase":"Change
description","user":"administrator","version":"1.0"}
Användning av EventSourcing
Separat rapportmodell

     Server




      Atom    Consumer   Rapportdatabas




              Consumer   Rapportdatabas
Multipel persistens

      Server     Lucene    Neo4j




      Atom     Consumer   Consumer
Application Events

      Server




      Atom




    Consumer   “SentEmailEvent”   SendEmailService
Replikering

     Master   Slave             Slave




      Atom




                      Staging
Backup



✤   Ta snapshot backup varje natt

✤   Ta kontinuerlig backup av events via replikering

✤   Vid restore: ta tillbaka snapshot och gör replay på events
Audit log / debugging


✤   Kan se alla operationer som gjorts, av vem, och när

    ✤   Juridiskt användbart

    ✤   Debugging av modellen

✤   Vilka funktioner används mest? Minst?
Q&A


✤   rickard.oberg@jayway.com

✤   qi4j.org

    ✤   qi4j-library-eventsourcing

    ✤   qi4j-library-eventsourcing-jdbm

    ✤   qi4j-library-eventsourcing-rest

Más contenido relacionado

Destacado

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destacado (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

EventSourcing applied

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n