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

KanDDDinsky Berlin 2017: Let Your Domain Events Flow

KanDDDinsky Berlin 2017: Let Your Domain Events Flow

2999fab21d182294fad0b2cc590fd54d?s=128

Martin Schimak

October 20, 2017
Tweet

Transcript

  1. Let your domain events flow KanDDDinsky, Oct 20th, 2017, Berlin,

    Germany mail@bernd-ruecker.com martin.schimak@plexiti.com With thoughts from http://flowing.io @berndruecker | @martinschimak
  2. Bernd Rücker Consultant & Dev. Advocate 10+ years workflow Co-founder

    Camunda http://bernd-ruecker.com/ Martin Schimak Developer & Trainer, 10+ years (de-)coding domain knowledge DDDesign, TDD/BDD, EDA http://plexiti.com/ http://flowing.io/
  3. None
  4. Simplified example: dash button Photo by 0xF2, available under Creative

    Commons BY-ND 2.0 license. https://www.flickr.com/photos/0xf2/29873149904/
  5. Three steps…

  6. Who is involved? Checkout Payment Inventory Shipment

  7. Looking into events… Checkout Payment Inventory Shipment Domain Events are

    facts that happened in the past Good Fetched Good Stored Read Model Write Model „The button blinks green if we can ship the item within 24 hours!“
  8. Peer-to-peer event flows Checkout Payment Inventory Shipment Payment received Order

    placed Goods fetched
  9. Peer-to-peer event flows Checkout Payment Inventory Shipment Payment received Order

    placed Goods fetched Please fetch the goods before waiting for payment Some customers can pay via invoice …
  10. Some requirements don‘t fit anywhere… What are we missing? Order

    Checkout Payment Inventory Shipment
  11. Commands can decrease coupling Order Checkout Payment Inventory Shipment Order

    placed Retrieve payment Commands have an intent about what needs to happen in the future Please fetch the goods before waiting for payment Some customers can pay via invoice Payment received Retrieve payment
  12. Good API design respects responsibility boundaries Order Checkout Payment Inventory

    Shipment „A few smart god services tell anemic CRUD services what to do!” Sam Newman What is the payment service responsible for?
  13. Some things in life take time

  14. A customer can update an expired credit card within two

    weeks before we cancel his order „
  15. Payment requires persitent state Order

  16. Pass around state as „routing slip“ Persist state with Entity,

    Actor, … State machine How to implement a Process Manager? DIY DIY
  17. State machine Persistent thing (Entity, Actor, …) Routing slip CADENCE

    Baker
  18. State machines solve some hard developer problems Monitoring & Operations

    Handling of time & timeouts Retry Visibility & Reporting Versioning Compensation Message correlation & deduplication Performance & scalability
  19. Leaving the aggregate scope?

  20. State machines solve some hard developer problems Monitoring & Operations

    Handling of time & timeouts Retry Visibility & Reporting Versioning Compensation Message correlation & deduplication Performance & scalability
  21. Bpmn.createProcess("order").executable() //... .sendTask().name("Retrieve payment").camundaClass(RetrievePayme .receiveTask().name("Payment received").message("PaymentReceive //... { "name": "retrieve_payment",

    "tasks": [ { "name": "Retrieve Payment", "taskReferenceName": "payment", "type": "SIMPLE", ... Do you prefer coded or graphical DSLs? * BPMN - ISO notation for modeling and executing long-running processes and flows
  22. Do you need a timeout?

  23. Do you need a compensation? *

  24. BPM?

  25. Flows done right Developer friendly Lightweight & composable BizDevOps

  26. None
  27. None
  28. More complex flows - transparent and directly executable

  29. Specifying and testing long-running behaviour

  30. A visual test report for example #1 (Balance = 50,

    Amount = 70)
  31. A visual test report for example #3 (Balance = 50,

    Amount = 30)
  32. The binding strategy uses the step only when required

  33. Living documentation for long-running behaviour

  34. Explicit language help in tackling complex event flows Ubiquitous Language

    Software Experts Domain Experts
  35. Explicit flows help sepatrate domain and infrastructure Ports and Adapters

    Application Domain Aggregates, Domain Events, Domain Services, etc … + the flow State machine
  36. Flows live inside the context boundaries

  37. Example Inventory Payment Order Shipping Checkout Monitor https://github.com/flowing/flowing-retail/ Human Tasks

  38. Live hacking

  39. Operational visibility in monitoring – possibly end-to-end

  40. None
  41. Mitigate tight coupling Consider core capabilities Leverage state machines Decentralize

  42. Thank you!

  43. Code online: https://github.com/flowing Slides & Blog: https://bernd-ruecker.com https://plexiti.com With thoughts

    from http://flowing.io @berndruecker | @martinschimak https://www.infoq.com /articles/microservice- event-choreographies
  44. Images licensed from iStock no attribution required All icons licensed

    from Noun Project no attribution required Images licensed under Creative Commons license Photo by 0xF2, available under Creative Commons BY-ND 2.0 license. https://www.flickr.com/photos/0xf2/2987 3149904/