Your SlideShare is downloading. ×
EventSourcing applied
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

EventSourcing applied

1,965
views

Published on

Description of EventSourcing, with code examples. Lists a number of possible usecases for EventSourcing

Description of EventSourcing, with code examples. Lists a number of possible usecases for EventSourcing

Published in: Technology

0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,965
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
46
Comments
0
Likes
5
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

    • 1. EventSourcing appliedRickard Öberg, JaywayDate
    • 2. Agenda✤ Domänmodeller och data✤ Vad är EventSourcing✤ Kodexempel✤ Användning av EventSourcing
    • 3. Domänmodeller och data
    • 4. Snapshots ORM
    • 5. Klient Snapshots ORM
    • 6. KlientServicefacade Snapshots ORM
    • 7. KlientServicefacade Snapshots ORM
    • 8. KlientServicefacadeDomänmodell Snapshots ORM
    • 9. KlientServicefacadeDomänmodell Snapshots ORM
    • 10. KlientServicefacadeDomänmodell SnapshotsDatalagring ORM
    • 11. KlientServicefacadeDomänmodell SnapshotsDatalagring ORM
    • 12. 3-i-1✤ Tre typer av data: ✤ Flaggor och status ✤ Fritext ✤ Rapportstöd
    • 13. Ändring av projektionen?✤ “Spara vem som gjorde vad och när”✤ “Ändra riktning på associationen”✤ “Lägg till beräkning”✤ “Fritextsökning!”
    • 14. Vad är EventSourcing
    • 15. Klient ServicefacadeDomänmodell Kommandon Events Eventlagring
    • 16. Kodexempel
    • 17. void setDescription(String newDescription){ description().set(newDescription);}
    • 18. void changeDescription(String newDescription){ if (... description is ok ...) changedDescription(newDescription);}@DomainEventvoid changedDescription(String newDescription){ description().set(newDescription);}
    • 19. UnitOfWork uow = unitOfWorkFactory.newUnitOfWork( UsecaseBuilder.newUsecase( "Changedescription" ));uow.metaInfo().set( administratorPrincipal );TestEntity entity = uow.newEntity( TestEntity.class );entity.changedDescription( "New description" );uow.complete();
    • 20. 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();}
    • 21. 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();}
    • 22. EventSource source = ...source.events( 0, Long.MAX_VALUE ).transferTo( Transforms.map( newFunction<UnitOfWorkDomainEventsValue, String>(){ public String map( UnitOfWorkDomainEventsValue unitOfWorkDomainEventsValue ) { return unitOfWorkDomainEventsValue.toJSON(); }}, Outputs.systemOut()));
    • 23. {"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":"Changedescription","user":"administrator","version":"1.0"}
    • 24. Användning av EventSourcing
    • 25. Separat rapportmodell Server Atom Consumer Rapportdatabas Consumer Rapportdatabas
    • 26. Multipel persistens Server Lucene Neo4j Atom Consumer Consumer
    • 27. Application Events Server Atom Consumer “SentEmailEvent” SendEmailService
    • 28. Replikering Master Slave Slave Atom Staging
    • 29. Backup✤ Ta snapshot backup varje natt✤ Ta kontinuerlig backup av events via replikering✤ Vid restore: ta tillbaka snapshot och gör replay på events
    • 30. 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?
    • 31. Q&A✤ rickard.oberg@jayway.com✤ qi4j.org ✤ qi4j-library-eventsourcing ✤ qi4j-library-eventsourcing-jdbm ✤ qi4j-library-eventsourcing-rest