complex event flows in
play

Complex event flows in distributed systems @berndruecker - PowerPoint PPT Presentation

Complex event flows in distributed systems @berndruecker @berndruecker 3 common hypotheses I check today: # Events decrease coupling # Orchestration needs to be avoided # Workflow engines are painful Warning: Contains Opinion Bernd Ruecker


  1. Complex event flows in distributed systems @berndruecker

  2. @berndruecker 3 common hypotheses I check today: # Events decrease coupling # Orchestration needs to be avoided # Workflow engines are painful

  3. Warning: Contains Opinion

  4. Bernd Ruecker Co-founder and Chief T echnologist of Camunda Berlin, Germany mail@berndruecker.io @berndruecker

  5. @berndruecker Simplified example: dash button Photo by 0xF2, available under Creative Commons BY-ND 2.0 license. https://www.flickr.com/photos/0xf2/29873149904/

  6. @berndruecker Three steps …

  7. @berndruecker Who is involved? Some bounded contexts … Checkout Shipment Payment Inventory

  8. @berndruecker (Micro-)services Checkout Shipment Payment Inventory

  9. @berndruecker Autonomous (micro-)services Checkout Dedicated Application Processes Dedicated infrastructure Shipment Payment Dedicated Development Teams Inventory

  10. Events decrease coupling @berndruecker

  11. @berndruecker Example The button blinks if we can ship within 24 hours Checkout Shipment Payment Inventory

  12. @berndruecker Request/response: temporal coupling The button blinks if we can ship within 24 hours Checkout Response Request Shipment Payment Inventory

  13. @berndruecker T emporal decoupling with events and read models The button blinks if we can ship within 24 hours Checkout Read Model Good Good Fetched Stored Shipment Payment Inventory *Events are facts about what happened (in the past)

  14. @berndruecker Event-driven architecture Order Checkout Placed Payment Notification Received Goods Fetched Shipment Payment Inventory

  15. @berndruecker Events can decrease coupling* *e.g. decentral data-management, read models, extract cross-cutting aspects

  16. @berndruecker Peer-to-peer event chains Order placed Checkout Shipment Payment Inventory Goods shipped Payment Goods received fetched

  17. @berndruecker Peer-to-peer event chains Order placed Checkout Shipment Payment Inventory Goods shipped Payment Goods received fetched

  18. @berndruecker The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years. https://martinfowler.com/articles/201701-event-driven.html

  19. @berndruecker The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years. https://martinfowler.com/articles/201701-event-driven.html

  20. @berndruecker The danger is that it's very easy to make nicely decoupled systems with event notification, without realizing that you're losing sight of that larger-scale flow, and thus set yourself up for trouble in future years. https://martinfowler.com/articles/201701-event-driven.html

  21. @berndruecker Monitoring Workflows Across Microservices https://www.infoq.com/articles/monitor-workflow-collaborating-microservices

  22. T ypical approaches Distributed T racing Data Lake / Event Monitoring Process Mining Process T racking @berndruecker

  23. @berndruecker Stefan Tilkov: Microservice Patterns & Antipatterns - MicroXchg 2018

  24. @berndruecker Peer-to-peer event chains Fetch the goods before the Order payment placed Checkout Shipment Payment Inventory Goods shipped Payment Goods received fetched

  25. @berndruecker Peer-to-peer event chains Fetch the goods before the Order payment placed Checkout Shipment Payment Inventory Goods shipped Payment Goods received fetched

  26. @berndruecker Photo by born1945, available under Creative Commons BY 2.0 license.

  27. @berndruecker What we wanted Photo by Lijian Zhang, available under Creative Commons SA 2.0 License and Pedobear19 / CC BY-SA 4.0

  28. @berndruecker https://camunda.com/microservices-orchestration-survey-results-2018/ „ Challenges ?“ Source: Microservices orchestration survey, July 2018, 354 responses

  29. @berndruecker Extract the end-to-end responsibility Order placed Checkout Order Retrieve payment Payment Shipment Payment received Inventory *Commands have an intent about what needs to happen in the future

  30. @berndruecker It is about where to decide about the coupling! Order decides Order placed . to listen to the event Checkout . to issue the command Order Retrieve payment Shipment Payment Inventory

  31. @berndruecker It is about where to decide about the coupling! It can still be messaging! Order placed Checkout Order Retrieve payment Shipment Payment Inventory

  32. @berndruecker Commands help to avoid (complex) peer-to-peer event chains

  33. Orchestration needs to be avoided @berndruecker

  34. @berndruecker Smart ESB-like middleware Order Checkout Order placed Payment received Good Shipment fetched Payment Inventory Good shipped

  35. @berndruecker Dumb pipes Checkout Order Martin Fowler Smart endpoints Shipment Payment and dumb pipes Inventory

  36. @berndruecker Danger of god services? Checkout Order Sam Newmann A few Shipment smart god services Payment tell Inventory anemic CRUD services what to do

  37. @berndruecker Danger of god services? Checkout Order Sam Newmann A few Shipment Payment smart god services Inventory tell anemic CRUD services what to do

  38. @berndruecker A god service is only created by bad API design!

  39. @berndruecker Example Retrieve Payment Order Payment

  40. @berndruecker Example Retrieve Payment Credit Order Payment Card

  41. @berndruecker Example Retrieve Payment Credit Order Payment Card Rejected

  42. @berndruecker Example Retrieve Payment Credit Order Payment Card Rejected If the credit Rejected card was rejected, the customer can provide new details

  43. @berndruecker Example Retrieve Payment Credit Order Payment Card Rejected If the credit Rejected card was rejected, the customer can provide new details Client of dumb endpoints easily become a god services.

  44. @berndruecker Who is responsible to deal with problems? Retrieve Payment Credit Order Payment Card Payment If the credit Rejected card was received Payment rejected, the failed customer can provide new details

  45. @berndruecker Long running services Retrieve Payment Credit Order Payment Card Payment Rejected received Payment failed Smart endpoints are potentially long-running

  46. @berndruecker Handling State Persist thing State machine or (Entity, Actor, …) workflow engine DIY = effort, T ypical Scheduling, Versioning, accidental concerns operating, visibility, complexity scalability , …

  47. @berndruecker Workflow engines are painful Complex, proprietary, heavyweight, central, developer adverse, …

  48. @berndruecker Avoid the wrong tools! Low-code is great! (You can get rid of your developers!) Death by properties panel Complex, proprietary, heavyweight, central, developer adverse, …

  49. @berndruecker Workflow engines, state machines It is relevant in modern architectures

  50. @berndruecker Workflow engines, CADENCE state machines Silicon valley has recognized

  51. @berndruecker Workflow engines, CADENCE state machines

  52. @berndruecker public static void main(String[] args) { ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration() .buildProcessEngine(); engine.getRepositoryService().createDeployment() // .addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") // .startEvent() .serviceTask("Step1").camundaClass(SysoutDelegate.class) What do I mean by .serviceTask("Step2").camundaClass(SysoutDelegate.class) .endEvent() .done() „ leightweight ?“ ).deploy(); engine.getRuntimeService().startProcessInstanceByKey( "flow", Variables.putValue("city", "New York")); } public class SysoutDelegate implements JavaDelegate { public void execute(DelegateExecution execution) throws Exception { System.out.println("Hello " + execution.getVariable("city")); } }

  53. @berndruecker public static void main(String[] args) { Build engine ProcessEngine engine = new StandaloneInMemProcessEngineConfiguration() in one line of .buildProcessEngine(); code engine.getRepositoryService().createDeployment() // (using in- .addModelInstance("flow.bpmn", Bpmn.createExecutableProcess("flow") // memory H2) .startEvent() .serviceTask("Step1").camundaClass(SysoutDelegate.class) .serviceTask("Step2").camundaClass(SysoutDelegate.class) .endEvent() .done() ).deploy(); engine.getRuntimeService().startProcessInstanceByKey( "flow", Variables.putValue("city", "New York")); } public class SysoutDelegate implements JavaDelegate { public void execute(DelegateExecution execution) throws Exception { System.out.println("Hello " + execution.getVariable("city")); } }

Recommend


More recommend