Publicité
Publicité

Contenu connexe

Plus de Mauro Servienti(20)

Publicité

Welcome to the (state) machine @ Xe One Day Enterprise Applications

  1. #XeOneDay Evento realizzato grazie al supporto di
  2. welcome to the (state) machine It’s all right, I know where you’ve been mauroservienti Mauro Servienti
  3. All I want to do when I wake up in the morning is… (cit. Rosanna, Toto, Toto IV) mauroservienti
  4. mauroservienti
  5. buy ticket(s) stage dive… :-) mauroservienti
  6. All what they want to do is… mauroservienti
  7. mauroservienti
  8. display available tickets reserve ticket(s) charge my credit card deal with insurance ship ticket(s) deal with their stuff mauroservienti
  9. sometimes order doesn’t matter sometimes it does! mauroservienti
  10. Process Manager Connecting the dots… mauroservienti
  11. Tickets Selection Credit Card Gateway/ACL Orders Manager Checkout request AuthorizeCard request/response Reservation Gateway/ACL ConfirmTickets request/response Credit Card Gateway/ACL ChargeCard request/response Insurance Gateway/ACL TicketsInsurance request/response Shipping Gateway/ACL Shiptickets request/response 2-phase commit (kind-of) … mauroservienti Reservation Gateway/ACL SelectTickets request/response
  12. 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 mauroservienti
  13. mauroservienti like a Punch Card, a Process Manager owns the process
  14. Ticket(s) Stuff… Insurance mauroservienti
  15. Process Managers, a source of coupling •Violates Single Responsibility Principle •Contention/Performance Bottleneck •Conflicting Changes/Merge Conflicts •Single Unit of Deployment •Single Point of Failure mauroservienti
  16. user mental model tends to be UI driven mauroservienti
  17. there is no Spoon Orders Manager mauroservienti
  18. chop up mauroservienti
  19. Autonomy Collaborative Domains mauroservienti
  20. sagas autonomy in collaborative domains mauroservienti
  21. multiple workflows, each providing compensating actions for every step of the workflow where it can fail mauroservienti
  22. multiple workflows, each providing compensating actions for every step of the workflow where it can fail mauroservienti
  23. reserve with the theater charge my credit card deal with insurance ship tickets deal with their stuff mauroservienti
  24. reservation finance insurance shipping stuff mauroservienti
  25. Shipping Finance Tickets Ordering Saga mauroservienti ReservationOrder Checked-out Payment Authorized Order Created Payment Succeeded Available Tickets Select tickets Shopping Cart Proceed to checkout workflow workflow workflow
  26. Shipping Finance Tickets Ordering Saga mauroservienti ReservationOrder Checked-out Payment Authorized Order Created Payment Succeeded Available Tickets Select tickets Shopping Cart Proceed to checkout Policy Policy Policy
  27. Shipping Finance mauroservienti Reservation Available Tickets Select tickets Shopping Cart Proceed to checkout Policy Policy Policy Order Checked-out Payment Authorized Order Created Payment Succeeded Pivotal Events
  28. mauroservienti Let’s open the black box
  29. Shipping ReservationPayment Gateway Finance Finance Initiate Payment Authorize Card Courier Gateway Tickets Ordering Saga mauroservienti Available Tickets Select tickets Reservation Shopping Cart Proceed to checkout Reservation Order Checked-out Payment Authorized Order CreatedFinance Payment Gateway Charge Card Payment Succeeded Delivery Pick-up Order Shipped
  30. multiple workflows, each providing compensating actions for every step of the workflow where it can fail mauroservienti
  31. Shipping ReservationPayment Gateway Finance Finance Initiate Payment Authorize Card Courier Gateway Tickets Ordering Saga mauroservienti Available Tickets Select tickets Reservation Shopping Cart Proceed to checkout Reservation Order Checked-out Payment Authorized Order CreatedFinance Payment Gateway Charge Card Payment Succeeded Delivery Pick-up Order Shipped
  32. Payment Gateway Finance Finance Initiate Payment Authorize Card Payment Policy mauroservienti Order Checked-out Payment Authorized Finance Payment Gateway Charge Card Payment Succeeded
  33. Payment Gateway Finance Finance Initiate Payment Authorize Card Payment Policy mauroservienti Order Checked-out Payment Authorized 48hrs to release money
  34. Payment Gateway Finance Finance Initiate Payment Authorize Card Payment Policy mauroservienti Order Checked-out Payment Authorized Finance Payment Gateway Charge Card Payment Succeeded 48hrs to release money Payment Gateway Release Money Reserved?N Y Do nothing… Reservation Order Created 48hrs later…
  35. New requirement • A ticket must be purchased within 10 minutes mauroservienti
  36. Shipping ReservationPayment Gateway Finance Finance Initiate Payment Authorize Card Courier Gateway Tickets Ordering Saga mauroservienti Available Tickets Select tickets Reservation Shopping Cart Proceed to checkout Reservation Order Checked-out Payment Authorized Order CreatedFinance Payment Gateway Charge Card Payment Succeeded Delivery Pick-up Order Shipped
  37. Reservation Reservation Policy mauroservienti Available Tickets Select tickets Reservation Tickets Reserved 10’ to purchase Reservation Release Tickets N Y Do nothing… Checked-out?Reservation Expired
  38. Shipping ReservationPayment Gateway Finance Finance Initiate Payment Authorize Card Courier Gateway Tickets Ordering Saga mauroservienti Available Tickets Select tickets Reservation Tickets Added to Cart Reservation Shopping Cart Proceed to checkout Reservation Order Checked-out Payment Authorized Order CreatedFinance Payment Gateway Charge Card Payment Succeeded Delivery Pick-up Order Shipped 10’ to purchase 48hrs to release money
  39. New requirement • 12-hours delivery SLA with our customers • if the default shipping courier doesn't respond • contact another one to deliver the package mauroservienti
  40. Shipping ReservationPayment Gateway Finance Finance Initiate Payment Authorize Card Courier Gateway Shipping Policy mauroservienti Available Tickets Select tickets Reservation Tickets Added to Cart Reservation Shopping Cart Proceed to checkout Reservation Order Checked-out Payment Authorized Order CreatedFinance Payment Gateway Charge Card Payment Succeeded Delivery Pick-up Order Shipped 10’ to purchase 48hrs to release money
  41. Shipping Order Shipped … First Courier Gateway Pick-up Request Shipping Shipping Second Courier Gateway Pick-up Request Shipping Shipping Have we received a response? Shipment Failed … mauroservienti 8hrs timeout Shipping Policy Have we received a response? ? 2hrs escalation timeout N N?Y Y
  42. Concurrency 1. Pick-up request to 1st courier 2. 8 hours go by 3. No response yet 4. Pick-up request to 2nd courier 5. 2nd courier replies 6. 1st courier replies…Ooops mauroservienti
  43. mauroservienti It’s a business problem
  44. Sagas (a different point of view) OrderId ShippingId ShippingStatus Etc 12 1337 Delivered … 58 1338 Pending … Orders table Reservation Shipping Finance Id TicketId 12 ABC 58 ACD Reservations table OrderId Address 12 Haifa, Israel 58 Rotterdam, Holland Shipping table OrderId Status 12 Paid 58 Overdue Invoices table VS mauroservienti
  45. Sagas (a different point of view) Reservation Shipping Finance Id TicketId 12 ABC 58 ACD Reservations table OrderId Address 12 Haifa, Israel 58 Rotterdam, Holland Shipping table OrderId Status 12 Paid 58 Overdue Invoices table mauroservienti Each service can evolve independently
  46. Sagas •Business Process is distributed •No overarching Process Manager •Respect Single Responsibility Principle •Independent scale out •Simpler/not conflicting evolution •Independent Units of Deployment mauroservienti
  47. Every year is getting shorter never seem to find the time… Sagas Demo bit.ly/xe-state-machine Udi Dahan about Sagas go.particular.net/xe-state-machine mauroservienti
  48. Demos: bit.ly/xe-state-machine Videos: go.particular.net/xe-state-machine Pitfalls • Monitor the (distributed) state mauroservienti
  49. Demos: bit.ly/xe-state-machine Videos: go.particular.net/xe-state-machine Pitfalls • Monitor the (distributed) state • There is no such thing as orchestration • Sagas spanning multiple services mauroservienti
  50. Demos: bit.ly/xe-state-machine Videos: go.particular.net/xe-state-machine Takeaways • Boundaries are key to success • Finding boundaries is the hardest part mauroservienti
  51. Demos: bit.ly/xe-state-machine Videos: go.particular.net/xe-state-machine Takeaways • Boundaries are key to success • Behaviors define how to designs processes • Follow the coupling, not the data • Identify processes and chop them up by “service” mauroservienti
  52. Demos: bit.ly/xe-state-machine Videos: go.particular.net/xe-state-machine Takeaways • Boundaries are key to success • Behaviors define how to designs processes • Use Delayed Messaging to model time • Simplifies making decisions in an async world mauroservienti
  53. @mauroservienti | #EDDD Mauro Servienti Solution Architect @ Particular Software the makers of NServiceBus mauro.servienti@particular.net @mauroservienti //github.com/mauroservienti //milestone.topics.it mauroservienti
  54. @mauroservienti | #EDDD Demos: bit.ly/xe-state-machine Videos: go.particular.net/xe-state-machine mauroservienti

Notes de l'éditeur

  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. Quick detour on the overall complexity
  4. No scatter/gather Too many messages
  5. No scatter/gather Too many messages
Publicité