Slide 1

Slide 1 text

Domain Events & Event Storming Michael Plöd @bitboss

Slide 2

Slide 2 text

Credits 
 to
 Eric Evans Vaughn Vernon
 Alberto Brandolini Sources: Books by Eric Evans, Alberto Brandolini and Vaughn Vernon

Slide 3

Slide 3 text

„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“

Slide 4

Slide 4 text

Ubiquitous Language?

Slide 5

Slide 5 text

!Domain Events are something that happened that Domain Experts care about

Slide 6

Slide 6 text

! Model information about activity in the domain as a series of discrete events.

Slide 7

Slide 7 text

Events are easy to grasp Events have a simple semantic Events can be placed 
 on a timeline

Slide 8

Slide 8 text

An event is something 
 that happened in the past t now Event Event Event Event Event

Slide 9

Slide 9 text

The names of the events are part of the
 Ubiquitous Language D D D

Slide 10

Slide 10 text

ShipmentDeliveredEvent
 CustomerVerifiedEvent CartCheckedOutEvent CreateCustomerEvent
 WillSaveItemEvent
 DoStuffEvent

Slide 11

Slide 11 text

Triggers of Events Documents Time Applications User Actions Other Events

Slide 12

Slide 12 text

! A Domain Event is always immutable

Slide 13

Slide 13 text

Scope your events based on
 Aggregates D D D

Slide 14

Slide 14 text

Commands can change business object 
 state. Which can result in one or more Events being published Command Business
 Object Event Event Event

Slide 15

Slide 15 text

Command Event ShipOrderCommand OrderShippedEvent DecideCreditApplicationCommand CreditDecisionPositive
 CreditDecisionNegative AddCommentCommand CommentAdded LockCreditApplication CreditApplicationLocked

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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
 consumer

Slide 18

Slide 18 text

CustomerCreatedEvent { "eventId": "4567854", "eventTimetamp": „12398989343", "eventType": "CustomerCreatedEvent", "url": "http://123.03.24.23/event/2" } 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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

CustomerCreatedEvent { "eventId": "4567854", "eventTimetamp": „12398989343", "eventType": "CustomerCreatedEvent", "customerLastName": "Plöd", "customerNumber": "34ed2345", "url": "http://123.03.24.23/event/2"
 } MIX Events contain some data Additional data can be obtained 
 by calling as REST Resource Good compromise in many 
 occasions

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Credit
 Application
 Number
 Generated Application
 Process Credit Decision Credit Application Credit
 Details
 Entered Financial
 Situation
 Entered

Slide 26

Slide 26 text

Credit
 Application
 Entered Credit Application Customer Scoring Customer Created

Slide 27

Slide 27 text

Scoring Positive Scoring Scoring Negative Credit Decision Application Declined Application Approved

Slide 28

Slide 28 text

How do I identify events?

Slide 29

Slide 29 text

Event Storming !

Slide 30

Slide 30 text

Overview > Workshop moderation format > Invented by Alberto Brandolini > Analysis of requirements based on events Source: http://ziobrando.blogspot.de/2013/11/introducing-event-storming.html

Slide 31

Slide 31 text

Event Storming is highly analog

Slide 32

Slide 32 text

Invite the right people Provide unlimited 
 modelling space Explore the domain starting 
 from Domain Events Explore the the origins of Domain Events Look for Aggregates Source: http://ziobrando.blogspot.de/2013/11/introducing-event-storming.html Avoid tables / chairs
 in the room

Slide 33

Slide 33 text

Use A LOT of sticky notes Events External Systems External Organizations Artefacts Source: http://ziobrando.blogspot.de/2013/11/introducing-event-storming.html

Slide 34

Slide 34 text

Event Storming

Slide 35

Slide 35 text

Bonus Targets > Explore Subdomains > Explore Bounded Contexts > Sketch User Personas > Sketch Key Acceptance Tests > Sketch Key Read Model Artefacts Source: http://ziobrando.blogspot.de/2013/11/introducing-event-storming.html

Slide 36

Slide 36 text

Thank you shameless plug: we offer DDD trainings & consulting Michael Plöd @bitboss