TechDays 2017 - Event Sourcing after launch how to evolve your event store along with your application

TechDays 2017 - Event Sourcing after launch how to evolve your event store along with your application

Event sourcing can be a solution for certain problems in your application, but it also comes with its own set of challenges.
One of those is the evolution of your event schema. How should you handle changes to events?
We found many approaches while doing our research (we’ve published earlier results in our paper “The Dark Side of Event Sourcing”) and we gained a lot of experienced from building a full-size ERP application using CQRS and event sourcing.
In this talk we will show what kind of approaches we’ve found and what we use to deal with our specific challenges. We will also share early research results from our interviews with over 20 different companies using event sourcing.
Every request for advice can be answered with ‘it depends’, and this talk will not solve that. But we will tell you what your options are, what we think works, and what many others have done.

03dc1d993fa7d5de422c1f35d53f80e6?s=128

Michiel Overeem

October 12, 2017
Tweet

Transcript

  1. michiel.overeem@afas.nl @michielovereem

  2. 400+ employees (4 locations) 10.500 customers (companies) AFAS Software

  3. HRM, CRM, finance, order management, project management, workflow, ... AFAS

    Profit
  4. None
  5. accountId balance owner 1234567 0 Michiel Current state Event sourcing

    Event BankAccountCreated (accountId: 1234567, balance: 0, owner: Michiel)
  6. accountId balance owner 1234567 100 Michiel Current state Event sourcing

    Event BankAccountCreated (accountId: 1234567, balance: 0, owner: Michiel) DepositPerformed (accountId : 1234567, amount: 100, balance: 100)
  7. Event BankAccountCreated (accountId: 1234567, balance: 0, owner: Michiel) DepositPerformed (accountId

    : 1234567, amount: 100, balance: 100) WithdrawalPerformed (accountId: 1234567, amount: 50, balance: 50) accountId balance owner 1234567 50 Michiel Current state Event sourcing
  8. Event BankAccountCreated (accountId: 1234567, balance: 0, owner: Michiel) DepositPerformed (accountId

    : 1234567, amount: 100, balance: 100) WithdrawalPerformed (accountId: 1234567, amount: 50, balance: 50) OwnerChanged (accountId: 1234567, newOwner: Marten) accountId balance owner 1234567 50 Marten Current state Event sourcing
  9. None
  10. Event ShoppingCartCreated (cartid: 1234567, user: Michiel) cartid articles user 1234567

    0 Michiel Current state Event sourcing
  11. Event ShoppingCartCreated (cartid: 1234567, user: Michiel) ArticleAddedToCart(cartid: 1234567, article: Lumia

    950) cartid articles user 1234567 1 Michiel Current state Event sourcing cartid article 1234567 Lumia 950
  12. cartid articles user 1234567 0 Michiel Current state Event sourcing

    cartid article Event ShoppingCartCreated (cartid: 1234567, user: Michiel) ArticleAddedToCart(cartid: 1234567, article: Lumia 950) ArticleRemovedFromCart(cartid: 1234567, article: Lumia 950)
  13. cartid articles user 1234567 1 Michiel Current state Event sourcing

    cartid article 1234567 iPhone X Event ShoppingCartCreated (cartid: 1234567, user: Michiel) ArticleAddedToCart(cartid: 1234567, article: Lumia 950) ArticleRemovedFromCart(cartid: 1234567, article: Lumia 950) ArticleAddedToCart(cartid: 1234567, article: iPhone X)
  14. cartid articles user 1234567 1 Michiel Current state Event sourcing

    cartid article 1234567 iPhone X Event ShoppingCartCreated (cartid: 1234567, user: Michiel) ArticleAddedToCart(cartid: 1234567, article: Lumia 950) ArticleRemovedFromCart(cartid: 1234567, article: Lumia 950) ArticleAddedToCart(cartid: 1234567, article: iPhone X)
  15. None
  16. None
  17. None
  18. None
  19. None
  20. Copyright Nasa Goddard But there is a dark side… How

    can we handle changes? What is the best way for our context?
  21. A stream of events

  22. None
  23. Multiple streams

  24. { “ArticleAddedToCart”: { “cartid”: 1234567, “article”: “Lumia 950” } }

  25. None
  26. Webshop EventStore Customer Stream ShoppingCart Stream CustomerSignedUp { … }

    PriviligeUpgraded { … } ShoppingCartCreated { … } ChangedQuantityOfArticle { … } ArticleAddedToChart { … }
  27. None
  28. Customer Stream CustomerSignedUp { …, newsletter: <bool> } PriviligeUpgraded {

    … }
  29. Customer Stream CustomerSignedUp { … } PriviligeUpgraded { … }

    OptInOnNewsLetter { … }
  30. Newsletter Stream CreateNewsletter { … } PublishNewsletter { … }

  31. Customer Stream CustomerSignedUp { …, firstName: <string>, surName: <string> }

    PriviligeUpgraded { … } CustomerSignedUp { …, fullName: <string> }
  32. Customer Stream CustomerSignedUp { … } PriviligeUpgraded { … }

    OptInOnNewsLetter { … } CustomerSignedUp { …, newsletter: <bool> }
  33. Customer Stream CustomerSignedUp { … } PriviligeUpgraded { … }

    OptInOnNewsLetter { … } Customer Stream CustomerSignedUp { … } PriviligeUpgraded { … } NewsletterSubscription Stream OptInOnNewsLetter { … }
  34. Store level operations Add / remove streams Merge streams /

    split / … streams Stream level operations Add / remove events Merge events / split / … events Event level operations Add / update / remove attributes Merge attributes / split / … attributes
  35. None
  36. Copyright Stephen Cairns

  37. Client

  38. Client

  39. Client

  40. None
  41. Customer Stream CustomerSignedUp { … } PriviligeUpgraded { … }

    CustomerSignedUpV2 { …, newsletter: <bool> }
  42. Customer Stream CustomerSignedUp { … } PriviligeUpgraded { … }

  43. Client Upcaster

  44. Client Upcaster

  45. Updater Not for the faint of heart!

  46. Updater

  47. Updater

  48. Multiple versions Weak schema Upcasters Lazy transformation In place transformation

    Copy and transformation Functional suitability +/- - +/- +/- + +
  49. Multiple versions Weak schema Upcasters Lazy transformation In place transformation

    Copy and transformation Maintainability - +/- +/- +/- + +
  50. Multiple versions Weak schema Upcasters Lazy transformation In place transformation

    Copy and transformation Performance efficiency + + + +/- +/- -
  51. Multiple versions Weak schema Upcasters Lazy transformation In place transformation

    Copy and transformation Reliability + + + - - +
  52. None
  53. None
  54. None
  55. None
  56. None
  57. None
  58. None
  59. None
  60. None
  61. michiel.overeem@afas.nl @michielovereem https://dev.afas.nl