Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Event sourcing with Marten

Event sourcing with Marten

devNetNoord

October 18, 2022
Tweet

More Decks by devNetNoord

Other Decks in Programming

Transcript

  1. • What is event sourcing? • Building your first event

    sourced logic • Adding Projections • Other concerns Agenda
  2. An event sourced approach API Command handler Domain class C

    Repository C E E E Projection E Repository S S Q S
  3. • In case you need an audit log of every

    action • Point-in-time restore of the state based on past events • Scale read operations and write operations separately Why would you use event sourcing?
  4. • It doesn’t feel natural at first. • It is

    more work to build an event sourced system. • Performance profile can be harder to manage Event sourcing comes at a price!
  5. • Document database • Uses Postgresql database • Supports event

    sourcing Introducing Marten into the picture
  6. • Whenever we want to read, we need to replay

    events. • Projection provided by aggregate often not enough. • Have you tried combining several aggregates? Why do you need projections?
  7. Synchronous projections • Great for generating views • Run in

    the same transaction • Can generate multiple documents • Run in separate transaction • At least once processing • Useful for integrating with other data outputs Two types of projections in Marten Asynchronous projections
  8. • Event sourcing can be quite useful in more complex

    domains • Marten provides an excellent approach to it • Please be aware of the costs Summary