34
Event sourcing in practice lessons learned. Mikael Sundberg @msundb

Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

  • Upload
    others

  • View
    10

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Event sourcing in practice lessons learned.

Mikael Sundberg @msundb

Page 2: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Event sourcing?

Store events instead of current state

Page 3: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Testing

Page 4: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Testing

Old events need to work

Write raw events to database

Page 5: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

MonitoringUsed to monitor what went wrong

Page 6: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

MonitoringHow do you know that something that should have happened didn't happen?

Page 7: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 8: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

MonitoringBreadcrumbs!

Page 9: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 10: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 11: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 12: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Protect your domainYou are not a message bus

Page 13: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 14: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 15: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 16: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 17: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Protect your domainDon't let your domain become fat.

Page 18: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Event schema● Avro● Protobuff

Page 19: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Ordering of events

Some messages are faster than others

Page 20: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 21: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 22: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 23: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 24: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 25: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Ordering of events

Network can cause messages to lose order

Page 26: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 27: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 28: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 29: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 30: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing
Page 31: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Events are in order!

Page 32: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

The good

● Your queries are always fast● Replicating immutable data is easy● You can’t query the data easily● Encourages good domain models● Nothing is ever deleted

Page 33: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Imageshttps://www.flickr.com/photos/eltpics/13664102064https://www.flickr.com/photos/54257797@N07/5210582753https://commons.wikimedia.org/wiki/File:Mocking_Bird_Argument.jpghttps://commons.wikimedia.org/wiki/File:Pigeon_silhouette_4874.svghttp://www.publicdomainpictures.net/view-image.php?image=147003&picture=sad-face-ostrichhttps://upload.wikimedia.org/wikipedia/commons/0/09/Sitta-carolinensis-001.jpghttps://www.flickr.com/photos/alancleaver/4204419570https://upload.wikimedia.org/wikipedia/commons/5/50/Gall-dindi.jpghttp://maxpixel.freegreatpicture.com/White-Stream-Winter-Snow-Swans-Nature-Bird-1323089http://maxpixel.freegreatpicture.com/Bird-Breadcrumbs-Wrought-Iron-652575https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/BirdBeaksA.svg/465px-BirdBeaksA.svg.pnghttps://www.flickr.com/photos/kumarsedit/15481104857https://www.flickr.com/photos/malingering/8129080389https://commons.wikimedia.org/wiki/File:Birds.jpghttps://upload.wikimedia.org/wikipedia/commons/7/71/Cacatua_moluccensis_excited.jpg

Page 34: Event sourcing in practice lessons learned. · Event sourcing in practice lessons learned. Mikael Sundberg @msundb. Event sourcing? Store events instead of current state. Testing

Thank you

[email protected]@msundb