Advertisement

Welcome to the (state) machine @ Crafted Software

Dec. 14, 2018
Advertisement

More Related Content

More from Mauro Servienti(20)

Advertisement

Welcome to the (state) machine @ Crafted Software

  1. @mauroservienti welcome to the (state) machine It’s all right, I know where you’ve been
  2. @mauroservienti All I want to do when I wake up in the morning is… (cit. Rosanna, Toto, Toto IV)
  3. @mauroservienti
  4. @mauroservienti tickets web site buy a ticket stage dive… :-)
  5. @mauroservienti All what they want to do is…
  6. @mauroservienti
  7. @mauroservienti display available tickets reserve with the theater charge my credit card deal with insurance ship tickets deal with their stuff
  8. @mauroservienti sometimes order doesn’t matter sometimes it does!
  9. @mauroservienti spot the
  10. @mauroservienti my ticket Warehouse Insurance
  11. @mauroservienti issuesOwnership is lost
  12. @mauroservienti
  13. @mauroservienti chop up
  14. @mauroservienti
  15. @mauroservienti
  16. @mauroservienti The (state) machine ticket ordering process
  17. @mauroservienti reserve with the theater charge my credit card deal with insurance ship tickets deal with their stuff The (state) machine
  18. @mauroservienti reservation payment insurance shipping stuff The (state) machine
  19. @mauroservienti Process Manager Connecting the dots…
  20. @mauroservienti Credit Card Gateway/ACL Orders Manager Checkout request Block off money request/response Reservation Gateway/ACL Reservation request/response Credit Card Gateway/ACL Charge credit card request/response Insurance Gateway/ACL Tickets Insurance request/response Shipping Gateway/ACL Ship tickets request/response 2-phase commit / timeout …
  21. @mauroservienti like a Punch Card, a Process Manager owns the process
  22. @mauroservienti Process Manager (a different point of view) New requirement: collect tickets at the venue OrderId ShippingId ShippingStatus Etc 12 1337 Delivered … 58 1338 Pending … Orders table
  23. @mauroservienti Process Managers: Source of coupling •Single Point of Failure •Violates Single Responsibility Principle •Contention/Performance Bottleneck •Conflicting Changes/Merge Conflicts •Single Unit of Deployment •Data exchange across boundaries
  24. @mauroservienti user mental model tends to be UI driven
  25. @mauroservienti there is no Spoon Orders Manager
  26. @mauroservienti Autonomy Collaborative Domains
  27. @mauroservienti Sagas
  28. @mauroservienti multiple workflows, each providing compensating actions for every step of the workflow where it can fail
  29. @mauroservienti multiple workflows, each providing compensating actions for every step of the workflow where it can fail
  30. @mauroservienti multiple workflows, each providing compensating actions for every step of the workflow where it can fail
  31. @mauroservienti Shipping Insurance Finance Reservation 1-day timeout to release money Payment Gateway Finance Order Checked-out Initiate Payment Policy Finance Hold money Venue Gateway Reserve seats Seats Reserved Payment Gateway Charge money Payment Succeeded Order Shipped …whatever … Courier Gateway Pick-up Request Tickets Ordering Saga
  32. @mauroservienti Shipping Insurance Finance Reservation 1-day timeout to release money Payment Gateway Finance Order Checked-out Initiate Payment Policy Finance Hold money Venue Gateway Reserve seats Seats Reserved Payment Gateway Charge money Payment Succeeded Order Shipped …whatever … Courier Gateway Pick-up Request Payment Policy Tickets Ordering Saga
  33. @mauroservienti New requirement • 12-hours delivery SLA with our customers • if the default shipping courier doesn't respond • contact another one to deliver the package
  34. @mauroservienti Shipping Insurance Finance Reservation 1-day timeout to release money Payment Gateway Finance Order Checked-out Initiate Payment Policy Finance Hold money Venue Gateway Reserve seats Seats Reserved Payment Gateway Charge money Payment Succeeded Order Shipped …whatever … Courier Gateway Pick-up Request Tickets Ordering Saga
  35. @mauroservienti Shipping Order Shipped … First Courier Gateway Pick-up Request 8-hours timeout Shipping Have we received a response? Shipping Yes No Second Courier Gateway Pick-up Request Shipping Shipping Policy 2-hours escalation timeout Shipping Have we received a response? Yes No Shipment Failed …
  36. @mauroservienti Payment Policy Shipping Policy Reservation Policy Seats Reserved Payment Succeeded Release money Order Checked-out fail 1-day timeout to release money Happy path and not so happy path :)
  37. @mauroservienti Payment Policy Customer Care … Reservation Policy Payment Failed Order Checked-out fail Happy path and not so happy path :)
  38. @mauroservienti Sagas (a different point of view) OrderId ShippingId ShippingStatus Etc 12 1337 Delivered … 58 1338 Pending … Orders table Sales Shipping Finance Id ProductId 12 ABC 58 ACD Orders table OrderId Address 12 Haifa, Israel 58 Rotterdam, Holland Shipping table OrderId Status 12 Paid 58 Overdue Invoices table VS
  39. @mauroservienti Sagas •Business Process is distributed •No overarching Process Manager •Respect Single Responsibility Principle •Independent scale out •Simpler/not conflicting evolution •Independent Units of Deployment
  40. @mauroservienti Takeaways • Boundaries are key to success • Finding boundaries is the hardest part
  41. @mauroservienti Takeaways • Boundaries are key to success • Mental model can badly influence design • Users/Business analysts tend to think in term of data presentation
  42. @mauroservienti Takeaways • Boundaries are key to success • Mental model can badly influence design • Behaviors define how to designs processes • Group data that change together • Follow the coupling • Identify processes and chop them up by “service”
  43. @mauroservienti Takeaways • Boundaries are key to success • Mental model can badly influence design • Behaviors define how to designs processes • Use Delayed Messaging to model time • Simplifies making decisions in an async world
  44. @mauroservienti | #EDDD Mauro Servienti Solution Architect @ Particular Software the makers of NServiceBus mauro.servienti@particular.net @mauroservienti //milestone.topics.it
  45. @mauroservienti | #EDDD Thank you!

Editor's Notes

  1. Ritmo tribale Litfiba
  2. Let me tell that you of that time when {the vendor I cannot name} gifted me with a nice {flat x86 device with a very thin keyboard} {the story} It’s obvious that there are two very different point of views here.
  3. Temporal coupling
  4. Compensation
  5. Idempotency
Advertisement