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

W-JAX 2017: Spring Boot Microservices mit Domain Events

W-JAX 2017: Spring Boot Microservices mit Domain Events

Domain Events sind ein zentraler Aspekt des taktischen Domain-driven Designs und zudem noch die Basis für die Implementierung lose gekoppelter Microservices, die auf asynchrones Event Processing ausgelegt sind. In diesem Vortrag werden wir uns mit dem Konzept der Domain Events beschäftigen und kennen lernen, wie sie modelliert und genutzt werden können, um eine lose Kopplung ohne synchrone Kommunikation von Microservices erreichen zu können.
Weiterhin werden wir das Konzept anhand eines konkreten Beispiels in die Praxis umsetzen. Hierbei werden wir Technologien wie Spring Boot, Spring Cloud Stream (Rabbit/Kafka) und Cloud Foundry verwenden, um anhand von Events und unterschiedlichen Modellierungsstilen von Events die Vor- und Nachteile des Ansatzes kennen zu lernen.


Michael Plöd

November 07, 2017

More Decks by Michael Plöd

Other Decks in Programming


  1. Spring Boot Microservices with Domain Events 
 Michael Plöd -

    innoQ @bitboss
  2. Your Trainer: Michael Plöd > Principal Consultant at innoQ >

    Regular Conference Speaker > Domain-Driven Design Practitioner since 2006 > Twitter: @bitboss > GitHub: https://github.com/mploed
  3. „After inserting data into“ „We need to check the status

    of“ „When we have called System X“ „If that happens“ „After the customer has“ „Notify me if“
  4. Ubiquitous Language?

  5. !Domain Events are something that happened that Domain Experts care

  6. ! Model information about activity in the domain as a

    series of discrete events.
  7. Events are easy to grasp Events have a simple semantic

    Events can be placed 
 on a timeline
  8. An event is something 
 that happened in the past

    t now Event Event Event Event Event
  9. The names of the events are part of the

    Language D D D
  10. ShipmentDeliveredEvent
 CustomerVerifiedEvent CartCheckedOutEvent CreateCustomerEvent

  11. Triggers of Events Documents Time Applications User Actions Other Events

  12. ! A Domain Event is always immutable

  13. Scope your events based on
 Aggregates D D D

  14. Commands can change business object 
 state. Which can result

    in one or more Events being published Command Business
 Object Event Event Event
  15. Command Event ShipOrderCommand OrderShippedEvent DecideCreditApplicationCommand CreditDecisionPositive
 CreditDecisionNegative AddCommentCommand CommentAdded LockCreditApplication

  16. Options for Event Payload Options Full Payload The event carries

    complete Entitiy-Graphs or Aggregates Mix The event contains data that is usually of interest to many other contexts. For special purposes there is also a URL to a RESTful HTTP Ressource Empty The event is empty or contains only minimal data and is being used to trigger pulling from a feed (eg. Atom) REST URL The event only carries a URL to a RESTful HTTP Ressource
  17. CustomerCreatedEvent { "eventId": "4567854", "eventTimetamp": „12398989343", "eventType": "CustomerCreatedEvent", "customerName": "Michael",

    "customerLastName": "Plöd", "customerNumber": "34ed2345", "address" : { "street": "Kreuzstr. 16", "postCode": "80331", "city": "München" } } Full Payload Events contain full object graphs Consumers do have all the data
 they need „Invitation“ to a high degree of
 coupling between event and
  18. CustomerCreatedEvent { "eventId": "4567854", "eventTimetamp": „12398989343", "eventType": "CustomerCreatedEvent", "url": ""

    } REST URL Events only contain a URL to a REST resource for the event data If consumers need the data they can obtain it but don’t have to Synchronous communication, but 
 no service discovery
  19. CustomerCreatedEvent { "eventId": "4567854", "eventTimetamp": „12398989343", "eventType": "CustomerCreatedEvent", } Empty

    Events contain no data at all Consumers would usually 
 consume an (ATOM) Feed Consumers need to know the 
 Source of the Feed
  20. CustomerCreatedEvent { "eventId": "4567854", "eventTimetamp": „12398989343", "eventType": "CustomerCreatedEvent", "customerLastName": "Plöd",

    "customerNumber": "34ed2345", "url": ""
 } MIX Events contain some data Additional data can be obtained 
 by calling as REST Resource Good compromise in many 
  21. An event is something 
 that happened in the past

    t now Event Event Event Event Event
  22. Let’s reuse the ESB from the failed SOA project

  23. NO

  24. NO

  25. NO

  26. ! Prefer dumb pipes with smart endpoints as a suitable

    message broker architecture
  27. Event Sourcing is an architectural pattern in which the state

    of the application is being determined by a sequence of events
  28. Case Study https://github.com/mploed/event-driven-spring-boot

  29. Start Application Enter
 Credit Details Enter Financial Situation Scoring Credit

  30. Credit
 Generated Application
 Process Credit Decision Credit Application

 Entered Financial
  31. Credit
 Entered Credit Application Customer Scoring Customer Created

  32. Scoring Positive Scoring Scoring Negative Credit Decision Application Declined Application

  33. https://github.com/mploed/event-driven-spring-boot

  34. THANK YOU I’ll post links to slides and code on

 Michael Plöd - innoQ @bitboss