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

OOP Munich Night School - EDA is More Than Even...

OOP Munich Night School - EDA is More Than Events - 3.2.2025

A tour of event-driven architecture in 22 bite sized chunks.

Lutz Hühnken

February 04, 2025
Tweet

More Decks by Lutz Hühnken

Other Decks in Programming

Transcript

  1. OOP 2025 Night School Event-Driven Architecture is More Than Events

    1 Links to Bluesky / LinkedIn / Blog: https://www.huehnken.de/
  2. 90 Minutes 22 Short Bits About Event-Driven Architecture 2 Links

    to Bluesky / LinkedIn / Blog: https://www.huehnken.de/
  3. 3 Please donʼt forget to rate the session at the

    end. I appreciate your feedback. ⭐⭐⭐⭐⭐
  4. Lutz Hühnken - https://www.huehnken.de/ Queries, Commands, Events 6 Is.. Expected

    Response Communication Pattern Query A request for information about the current state of one or many objects The requested information Request-Response Command An intention to perform an operation or change a state A confirmation that the command has been executed, or an error message if the command failed Request-Response Event A fact, something that undisputedly happened in the past None (events are facts, they can’t “fail”) Fire-and-Forget
  5. Lutz Hühnken - https://www.huehnken.de/ Event-Driven Architecture - Multiple services communicate

    via streams of events. - Between services (macroarchitecture) Event Sourcing - Instead of storing the current state, a sequence of events leading to that state is stored. - Within a service (microarchitecture) 9
  6. Lutz Hühnken - https://www.huehnken.de/ Why? Event-Driven Architecture - Decoupling of

    services, to improve scalability and resilience of the system. Event Sourcing - Capturing changes within a service as a sequence of immutable, time-ordered events, to make the entire history transparent and replayable. 12
  7. Lutz Hühnken - https://www.huehnken.de/ EDA helps us to battle two

    types of coupling: - Temporal Coupling (a.k.a. Runtime Coupling) (leading to better scalability and resilience) - Control Coupling (leading to enhanced organizational clarity / domain boundaries) 14
  8. 23 Recap: Basics 1. What Events Are 2. What Event

    Sourcing Is 3. The Why of EDA and Event Sourcing 4. Loose coupling is great. And a very broad term. 5. Events are both triggers and data Next: Implementation
  9. Lutz Hühnken - https://www.huehnken.de/ Event-Driven Architecture is technology agnostic. But

    there's a reason most people use log-based message brokers. Note they are architecturally fundamentally different from “store and forwardˮ queues. 25
  10. Lutz Hühnken - https://www.huehnken.de/ Itʼs inefficient. Donʼt try to turn

    your broker into a message queue. Better build efficient de-duplication and application-specific error handling. 33
  11. Lutz Hühnken - https://www.huehnken.de/ In Event Sourcing, you need to

    be able to restore the current state of your aggregate quickly, to enforce invariants. Use a Database, thank me later. See e.g. https://www.linkedin.com/posts/vaughnvernon_event-sourcing-and-mes sage-streaming-are-activity-7153936417142788097-gxTv 36
  12. Lutz Hühnken - https://www.huehnken.de/ Repeat until it works - allows

    event to be a “poison pillˮ. Can be ok. If not: Build your own (stash event, remember key as “blockedˮ, continue with others). Iirc Google Pub/Sub offers a bit more convenience. 39
  13. 43 Recap: Implementation 6. Log-based message brokers are a good

    fit for EDA 7. The transactional outbox is essential 8 ."Transactional Inbox" is an anti-pattern 9. Kafka is not good for event sourcing 10. Kafka consumer error handling is too basic 11. Itʼs not more more less complexity, it just moves elsewhere Next: Diving Deeper
  14. Lutz Hühnken - https://www.huehnken.de/ 47 47 Notification Events - Break

    the temporal decoupling - Break the event / state correlation - Recommendation: Only use to refer to immutable objects - Good use: Big, immutable data such as generated PDFs - Or: For big group of subscribers that are supposed to see different parts of the information?
  15. Lutz Hühnken - https://www.huehnken.de/ Maybe, instead of Event-Driven Architecture, we

    should talk about microworkflows? 61 Side project, coming sometime later this year: https://www.microworkflows.org/ )
  16. Lutz Hühnken - https://www.huehnken.de/ Think reducing complexity, not managing it.

    https://twitter.com/bitfield/status/1411731604335214592 70
  17. Lutz Hühnken - https://www.huehnken.de/ Examples for Things Youʼll Need to

    Accept 72 - Eventual Consistency - Partial Ordering - At-least-once Delivery
  18. Lutz Hühnken - https://www.huehnken.de/ 73 73 Donʼt fall into this

    trap. https://ronjeffries.com/xprog/articles/jatbaseball/
  19. 74 Recap: Diving Deeper 12. Use Notification events carefully 13.

    More About Commands Vs. Events 14. EDA is not only about events 15. It's important to keep your promises 16. Separate Observing From Control 17. Bring the Data to the Process 18. Don't fight complexity with complexity 19. Embrace constraints, donʼt fight them Next: The Principles are Everywhere
  20. Lutz Hühnken - https://www.huehnken.de/ 78 item, err := reserveItem(itemNumber) if

    err != nil { return nil, errors.New("out of stock") } confirmation, err := getPayment(itemNumber) if err != nil { return nil, errors.New("insufficient funds") } result, err := shipItem(itemNumber)
  21. Lutz Hühnken - https://www.huehnken.de/ Unix Philosophy 1. Make each program

    do one thing well. To do a new job, build afresh rather than complicate old programs by adding new "features". 2. Expect the output of every program to become the input to another, as yet unknown, program. ... 81 $ Cat file3.txt | grep “oop” | tee file4.txt | wc –l
  22. Lutz Hühnken - https://www.huehnken.de/ Tuple Spaces 83 A tuple space

    [..] provides a repository of tuples that can be accessed concurrently. As an illustrative example, consider that there are a group of processors that produce pieces of data and a group of processors that use the data. Producers post their data as tuples in the space, and the consumers then retrieve data from the space that match a certain pattern.
  23. Lutz Hühnken - https://www.huehnken.de/ Tuple Spaces 85 https://www.artima.com/articles/make-room-for-javaspaces-part-i (that’s where

    the picture on the previous slide is from) https://en.wikipedia.org/wiki/Tuple_space (that’s where the text on the slide before that is from) https://en.wikipedia.org/wiki/Jini
  24. 86 Recap: Basics 1. What Events Are 2. What Event

    Sourcing Is 3. The Why of EDA and Event Sourcing 4. Loose coupling is great. And a very broad term. 5. Events are both triggers and data
  25. 87 Recap: Implementation 6. Log-based message brokers are a good

    fit for EDA 7. The transactional outbox is essential 8 ."Transactional Inbox" is an anti-pattern 9. Kafka is not good for event sourcing 10. Kafka consumer error handling is too basic 11. Itʼs not more more less complexity, it just moves elsewhere
  26. 88 Recap: Diving Deeper 12. Use Notification events carefully 13.

    More About Commands Vs. Events 14. EDA is not only about events 15. It's important to keep your promises 16. Separate Observing From Control 17. Bring the Data to the Process 18. Don't fight complexity with complexity 19. Embrace constraints, donʼt fight them
  27. 89 Recap: The Principles are Everywhere 20. FP ❤ EDA

    21. The Unix Principle ❤ EDA 22. Blast From the Past: Tuple Spaces
  28. Lutz Hühnken - https://www.huehnken.de/ Event-Driven Architecture • enables scalability, resilience

    (removes temporal coupling) • promotes clear responsibility boundaries (removes control coupling) • enables stream processing 93
  29. 94 Links to Bluesky / LinkedIn / Blog: https://www.huehnken.de/ What

    do you think? Letʼs discuss! Please rate your experience ⭐⭐⭐⭐⭐