SlideShare a Scribd company logo
Concursus
Event Sourcing Evolved
GOTO  London  2016
Introductions
Dominic Fox
Twitter: @dynamic_proxy
Email: dominic.fox@opencredo.com
Tareq Abedrabbo
Twitter: @tareq_abedrabbo
Email: tareq.abedrabbo@opencredo.com
Concursus
Page: https://opencredo.com/publications/concursus/
Github: http://github.com/opencredo/concursus
Agenda
• History
• Concepts
• Example
• Domain model
• Processing model
• Programming model
• Future directions
What is Concursus?
A toolkit for processing and organising messy data in an distributed context.
The Concursus Timeline
Observations
Conception and design
Prototype
Open source implementation
Technical report and blogs
Event Sourcing
“Event Sourcing ensures that all changes to application state are stored as a sequence of
events. Not just can we query these events, we can also use the event log to reconstruct
past states, and as a foundation to automatically adjust the state to cope with retroactive
changes.”
http://martinfowler.com/eaaDev/EventSourcing.html
What is Concursus?
Problems Concursus addresses:
ü Processing events in a scalable and reliable way
ü Processing guarantees and ordering: exactly once, out of order, repeated or missed
delivery, etc..
ü Building meaningful domain models to reason about and build business logic around
ü Flexibility: building additional views as needed
Tendencies:
• From internet of users to internet of things
• From “presence” to “presents”
• From monoliths to microservices
Why Concursus?
From Internet of Users to Internet of Things
From Presence to Presents
From Monoliths to Microservices
“Write First, Reason Later”
2016-­‐10-­‐12  
09:06:31.432
Received  at  Depot
2016-­‐10-­‐12  
09:06:32.106
Received  at  Depot
2016-­‐10-­‐12  
09:06:34.740
Received  at  Depot
2016-­‐10-­‐12  
11:35:02.163
Loaded  onto  Truck
2016-­‐10-­‐12  
11:40:21.032
Loaded  onto  Truck
2016-­‐10-­‐12  
11:38:51.204
Loaded  onto  Truck
2016-­‐10-­‐12  
14:12:44.021
Delivery  Failed
2016-­‐10-­‐12  
15:00:31.322
Delivered
2016-­‐10-­‐12  
15:11:05.038
Delivered
“Write First, Reason Later”
Handling Events
ü Delivery constraints
out of order, repeated, delayed or missed delivery
ü Processing guarantees
at least once or exactly once processing, idempotency
ü Ordering
partial ordering across aggregates (with reasonable assumptions)
Data Processing Layers
ü Durable
sufficiently durable buffer for async processing (what’s happening)
ü Persistent
a permanent record of everything that has happened (what happened)
ü Transient
fast and consistent, but also disposable state (what happens)
Building Blocks
• Java 8 and Kotlin: APIs
• Cassandra: Persistent state (Event store)
• Kafka: Durable state (Message broker)
• Hazelcast: Transient state (cache, idempotency filters)
• Also, RabbitMQ and Redis
Sources of Inspiration
Stream processing frameworks such as Apache Storm and Spark
Google papers: Cloud dataflow, MillWheel
Apache Spark papers
The Axon CQRS framework
Domain Driven Design
Functional programming
Summary
Concursus
=
Event sourcing
+
Stream processing
+
Bounded contexts (DDD)
+
Distributed computing
Received  at
Depot
Loaded  onto  
Truck
Delivered
Delivery  Failed
Domain Model: Events
Received  
at
Depot
Loaded  
onto
Truck
Delivery
Failed
Received  
at
Depot
Loaded  
onto
Truck
Delivered
aggregateType: parcel
aggregateId: 69016fb5-1d69-4a34-
910b-f8ff5c702ad9
eventTimestamp: 2016-03-31 10:31:17.981
parameters: { “depotId”: “Lewisham” }
Domain Model: Events
Received  
at
Depot
Loaded  
onto
Truck
Delivery
Failed
Received  
at
Depot
Loaded  
onto
Truck
Delivered
aggregateType: parcel
aggregateId: 69016fb5-1d69-4a34-
910b-f8ff5c702ad9
eventTimestamp: 2016-03-38 08:15:23.104
parameters: { “truckId”: “J98 257” }
Domain Model: Events
Received  
at
Depot
Loaded  
onto
Truck
Delivery
Failed
Received  
at
Depot
Loaded  
onto
Truck
Delivered
eventTimestamp: 2016-03-31T10:36:42.171Z
processingTimestamp: 2016-03-31T10:36:48.3904Z
parameters: { “deliveryAddress”: “123 Sudbury
Avenue, Droitwich DR4 8PQ”}
Domain Model: Events
aggregateType: parcel
aggregateId: 69016fb5-1d69-4a34-
910b-f8ff5c702ad9
Received  at  Depot
Loaded  onto  Truck
Delivery  Failed
Received  at  Depot
Loaded  onto  Truck
Delivered
Domain Model: Summary
Every Event occurs to an Aggregate, identified by its type and id.
Every Event has an eventTimestamp, generated by the source of
the event.
An Event History is a log of Events, ordered by eventTimestamp,
with an additional processingTimestamp which records when the
Event was captured.
Network
Event sources Event processors
Events arrive:
• Partitioned
• Interleaved
• Out-of-order
Processing Model: Ordering
Log is:
• Partitioned by aggregate id
• Ordered by event timestamp
Processing Model: Ordering
CREATE  TABLE  IF  NOT  EXISTS  concursus.Event (
aggregateType text,
aggregateId text,
eventTimestamp timestamp,
streamId text,
processingId timeuuid,
name  text,
version  text,
parameters  map<text,  text>,
characteristics  int,
PRIMARY  KEY((aggregateType,  aggregateId),  eventTimestamp,  
streamId)
)  WITH  CLUSTERING  ORDER  BY  (eventTimestamp DESC);
Cassandra Schema
Cassandra
Event Store
RabbitMQ Topic
Downstream
processingLog
events
Publish
events
Cassandra & AMQP
Cassandra
Event Store
RabbitMQ Topic
Downstream
processing
out-of-order events
ordered query results
Cassandra & AMQP
Cassandra
Event Store
Kafka Topic
Downstream
processing
Event store
listener
Publish
events
Log
events
Cassandra & Kafka
Processing Model: Summary
Events arrive partitioned, interleaved and out-of-order.
Events are sorted into event histories by aggregate type and id.
Events are sorted within event histories by event timestamp, not
processing timestamp.
Event consumers need to take into account the possibility that an
event history may be incomplete at the time it is read – consider
using a watermark to give incoming events time to “settle”.
Programming Model: Core Metaphor
Received  
at
Depot
Loaded  
onto
Truck
Delivery
Failed
Received  
at
Depot
Loaded  
onto
Truck
Delivered
Received  
at
Depot
Loaded  
onto
Truck
Delivery
Failed
Received  
at
Depot
Loaded  
onto
Truck
Delivered
Consumer<Event>
Programming Model: Core Metaphor
You give me a Consumer<Event>, and I send Events to it one at a time:
Emitting Events
I implement Consumer<Event>, and handle Events that are sent to me.
Handling Events
Java 8 Mapping
Java 8 Mapping
Java 8 Mapping
Kotlin Mapping
sealed  class  ParcelEvent {
class  ReceivedAtDepot(val depotId:  String):  ParcelEvent()
class  LoadedOntoTruck(val truckId:  String):  ParcelEvent()
class  Delivered(val destinationId:  String):  ParcelEvent()
class  DeliveryFailed():  ParcelEvent()
}
Kotlin Mapping
eventBus.dispatchTo(parcelId,
ReceivedAtDepot(depotId =  "Lewisham Depot")  at  start,
LoadedOntoLorry(lorryId =  "Truck  CU50  ZCV")  at  
start.plus(2,  DAYS)
)
Kotlin Mapping
fun  describeEvent(event:  ParcelEvent):  Unit  =  when  (event)  {
is  ReceivedAtDepot -­‐>  println("Received  at  depot:  
${event.depotId}")
is  LoadedOntoTruck -­‐>  println("Loaded  onto  truck:  
${event.truckId}")
is  Delivered  -­‐>  println("Delivered  to:  
${event.destinationId}")
is  DeliveryFailed -­‐>  println("Delivery  failed")
}
Event-handling middleware is a chain of Consumer<Event>s that transforms, routes, persists
and dispatches events. A single event submitted to this chain may be:
■ Checked against an idempotency filter (e.g. a Hazelcast distributed cache)
■ Serialised to JSON
■ Written to a message queue topic
■ Retrieved from the topic and deserialised
■ Persisted to an event store (e.g. Cassandra)
■ Published to an event handler which maintains a query-optimised view of part of the system
■ Published to an event handler which maintains an index of aggregates by event property
values (e.g. lightbulbs by wattage)
Event-Handling Middleware
• Kafka Streams
• Narrative threads across event histories
• Generic Attribute indexing
• State management and caching
• Improved cloud tooling
Future Directions
Thank you for listening
Any questions?

More Related Content

PDF
The seven deadly sins of microservices
PDF
The seven more deadly sins of microservices final
PPTX
O'Reilly/Nginx 2016: "Continuous Delivery with Containers: The Trials and Tri...
PDF
muCon 2016: "Seven (More) Deadly Sins of Microservices"
PDF
Haufe #msaday: "Building a Microservice Ecosystem"
PDF
Reactive Principles and Microservices
PPTX
LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...
PDF
Open Source and Content Management (+audio)
The seven deadly sins of microservices
The seven more deadly sins of microservices final
O'Reilly/Nginx 2016: "Continuous Delivery with Containers: The Trials and Tri...
muCon 2016: "Seven (More) Deadly Sins of Microservices"
Haufe #msaday: "Building a Microservice Ecosystem"
Reactive Principles and Microservices
LJC Mashup "Building Java Microservices for the Cloud && Chuck Norris Doesn't...
Open Source and Content Management (+audio)

What's hot (10)

PDF
Microservices - Scaling Development and Service
PPTX
LJC: "Chuck Norris Doesn't Do DevOps...but Java developers might benefit"
PPTX
How to avoid microservice pitfalls
PDF
ServerlessConf: Serverless for the Enterprise - Rafal Gancarz
PPTX
Microservice Architecture
PPTX
DockerCon EU 2018 "Continuous Delivery with Docker and Java"
PPTX
JAX DevOps 2018 "Continuous Delivery Patterns for Modern Architectures"
PPTX
Cloud anti-patterns
PPTX
O'Reilly SACON NY 2018 "Continuous Delivery Patterns for Contemporary Archite...
PDF
Lisbon DevOps: "Seven (More) Deadly Sins of Microservices"
Microservices - Scaling Development and Service
LJC: "Chuck Norris Doesn't Do DevOps...but Java developers might benefit"
How to avoid microservice pitfalls
ServerlessConf: Serverless for the Enterprise - Rafal Gancarz
Microservice Architecture
DockerCon EU 2018 "Continuous Delivery with Docker and Java"
JAX DevOps 2018 "Continuous Delivery Patterns for Modern Architectures"
Cloud anti-patterns
O'Reilly SACON NY 2018 "Continuous Delivery Patterns for Contemporary Archite...
Lisbon DevOps: "Seven (More) Deadly Sins of Microservices"
Ad

Viewers also liked (19)

PDF
Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant
PDF
Voxxed Bristol 2017 - From C to Q, one event at a time: Event Sourcing illust...
PDF
Evolving Project Management: from the sin to the virtue by Antonio Cobo
PDF
Reactive Microservices By Lorenzo Nicora
PPTX
O'Reilly 2016: "Continuous Delivery with Containers: The Trials and Tribulati...
PDF
Haufe #msaday - Building a Microservice Ecosystem by Daniel Bryant
PDF
High Load Strategy 2016 - Project Management: from Stone Age to DevOps
PDF
A Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
PDF
muCon 2016: Authentication in Microservice Systems By David Borsos
PDF
QCON London 2017 - Monitoring Serverless Architectures by Rafal Gancarz
PDF
London Hashicorp Meetup #8 - Testing Programmable Infrastructure By Matt Long
PDF
Haufe #msaday - The Actor model: an alternative approach to concurrency By Lo...
PDF
Microservices Manchester: Microservices and Macro-Economics - A Shorty Histor...
PDF
Vault: Beyond secret storage - Using Vault to harden your infrastructure
PDF
Microservices Manchester: Security, Microservces and Vault by Nicki Watt
PPTX
Microservices Manchester: Authentication in Microservice Systems by David Borsos
PDF
Spring Boot Microservices vs Akka Actor Cluster
PPTX
ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...
PDF
Chronix as Long-Term Storage for Prometheus
Haufe #msaday - Seven More Deadly Sins of Microservices by Daniel Bryant
Voxxed Bristol 2017 - From C to Q, one event at a time: Event Sourcing illust...
Evolving Project Management: from the sin to the virtue by Antonio Cobo
Reactive Microservices By Lorenzo Nicora
O'Reilly 2016: "Continuous Delivery with Containers: The Trials and Tribulati...
Haufe #msaday - Building a Microservice Ecosystem by Daniel Bryant
High Load Strategy 2016 - Project Management: from Stone Age to DevOps
A Visual Introduction to Event Sourcing and CQRS by Lorenzo Nicora
muCon 2016: Authentication in Microservice Systems By David Borsos
QCON London 2017 - Monitoring Serverless Architectures by Rafal Gancarz
London Hashicorp Meetup #8 - Testing Programmable Infrastructure By Matt Long
Haufe #msaday - The Actor model: an alternative approach to concurrency By Lo...
Microservices Manchester: Microservices and Macro-Economics - A Shorty Histor...
Vault: Beyond secret storage - Using Vault to harden your infrastructure
Microservices Manchester: Security, Microservces and Vault by Nicki Watt
Microservices Manchester: Authentication in Microservice Systems by David Borsos
Spring Boot Microservices vs Akka Actor Cluster
ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...
Chronix as Long-Term Storage for Prometheus
Ad

Similar to GOTO LONDON 2016: Concursus Event sourcing Evolved (Updated) (20)

PDF
Building Microservices with Scala, functional domain models and Spring Boot -...
PDF
#JaxLondon: Building microservices with Scala, functional domain models and S...
PDF
Event Sourcing - what could go wrong - Jfokus 2022
PDF
Stateful Microservices with Apache Kafka and Spring Cloud Stream with Jan Svo...
PPTX
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...
PDF
Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...
PDF
Ingesting and Processing IoT Data - using MQTT, Kafka Connect and KSQL
PDF
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
PDF
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
PPTX
OpenWhisk: Where Did My Servers Go?
PDF
Spark (Structured) Streaming vs. Kafka Streams - two stream processing platfo...
PDF
Event sourcing - what could possibly go wrong ? Devoxx PL 2021
PDF
BBL KAPPA Lesfurets.com
PPTX
Fabric - Realtime stream processing framework
PPTX
Sparkling Water Webinar October 29th, 2014
PDF
Always on! Or not?
PDF
Implementing and Visualizing Clickstream data with MongoDB
PPSX
Auto Scaling for Multi-Tier Containers Topology
PPTX
Data Microservices In The Cloud + 日本語コメント
PDF
Spark Summit EU talk by Francois Garillot and Mohamed Kafsi
Building Microservices with Scala, functional domain models and Spring Boot -...
#JaxLondon: Building microservices with Scala, functional domain models and S...
Event Sourcing - what could go wrong - Jfokus 2022
Stateful Microservices with Apache Kafka and Spring Cloud Stream with Jan Svo...
FlinkForward Asia 2019 - Evolving Keystone to an Open Collaborative Real Time...
Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...
Ingesting and Processing IoT Data - using MQTT, Kafka Connect and KSQL
Dev fest 2020 taiwan how to debug microservices on kubernetes as a pros (ht...
Data processing platforms architectures with Spark, Mesos, Akka, Cassandra an...
OpenWhisk: Where Did My Servers Go?
Spark (Structured) Streaming vs. Kafka Streams - two stream processing platfo...
Event sourcing - what could possibly go wrong ? Devoxx PL 2021
BBL KAPPA Lesfurets.com
Fabric - Realtime stream processing framework
Sparkling Water Webinar October 29th, 2014
Always on! Or not?
Implementing and Visualizing Clickstream data with MongoDB
Auto Scaling for Multi-Tier Containers Topology
Data Microservices In The Cloud + 日本語コメント
Spark Summit EU talk by Francois Garillot and Mohamed Kafsi

More from OpenCredo (12)

PDF
Webinar - Design Thinking for Platform Engineering
PDF
MuCon 2019: Exploring Your Microservices Architecture Through Network Science...
PDF
Goto Chicago; Journeys To Cloud Native Architecture: Sun, Sea And Emergencies...
PPTX
Mucon 2018: Heuristics for Identifying Microservice Boundaries By Erich Eichi...
PDF
Journeys To Cloud Native Architecture: Sun, Sea And Emergencies - Nicki Watt
PDF
Machine Learning Game Changer for IT - Maartens Lourens
PDF
Kafka Summit 2018: A Journey Building Kafka Connectors - Pegerto Fernandez
PDF
MuCon 2017: A not So(A) Trivial Question by Tareq Abedrabbo
PDF
DevOpsCon Berlin 2017: Project Management from Stone Age to DevOps By Antoni...
PDF
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
PDF
Succeeding with DevOps Transformation - Rafal Gancarz
PDF
Progscon 2017: Serverless Architectures - Rafal Gancarz
Webinar - Design Thinking for Platform Engineering
MuCon 2019: Exploring Your Microservices Architecture Through Network Science...
Goto Chicago; Journeys To Cloud Native Architecture: Sun, Sea And Emergencies...
Mucon 2018: Heuristics for Identifying Microservice Boundaries By Erich Eichi...
Journeys To Cloud Native Architecture: Sun, Sea And Emergencies - Nicki Watt
Machine Learning Game Changer for IT - Maartens Lourens
Kafka Summit 2018: A Journey Building Kafka Connectors - Pegerto Fernandez
MuCon 2017: A not So(A) Trivial Question by Tareq Abedrabbo
DevOpsCon Berlin 2017: Project Management from Stone Age to DevOps By Antoni...
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Succeeding with DevOps Transformation - Rafal Gancarz
Progscon 2017: Serverless Architectures - Rafal Gancarz

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PDF
Modernizing your data center with Dell and AMD
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
A Presentation on Artificial Intelligence
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPT
Teaching material agriculture food technology
PDF
Encapsulation theory and applications.pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
Empathic Computing: Creating Shared Understanding
Modernizing your data center with Dell and AMD
Diabetes mellitus diagnosis method based random forest with bat algorithm
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Digital-Transformation-Roadmap-for-Companies.pptx
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Monthly Chronicles - July 2025
A Presentation on Artificial Intelligence
Review of recent advances in non-invasive hemoglobin estimation
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Big Data Technologies - Introduction.pptx
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
Teaching material agriculture food technology
Encapsulation theory and applications.pdf
Unlocking AI with Model Context Protocol (MCP)
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf

GOTO LONDON 2016: Concursus Event sourcing Evolved (Updated)

  • 2. Introductions Dominic Fox Twitter: @dynamic_proxy Email: dominic.fox@opencredo.com Tareq Abedrabbo Twitter: @tareq_abedrabbo Email: tareq.abedrabbo@opencredo.com Concursus Page: https://opencredo.com/publications/concursus/ Github: http://github.com/opencredo/concursus
  • 3. Agenda • History • Concepts • Example • Domain model • Processing model • Programming model • Future directions
  • 4. What is Concursus? A toolkit for processing and organising messy data in an distributed context.
  • 5. The Concursus Timeline Observations Conception and design Prototype Open source implementation Technical report and blogs
  • 6. Event Sourcing “Event Sourcing ensures that all changes to application state are stored as a sequence of events. Not just can we query these events, we can also use the event log to reconstruct past states, and as a foundation to automatically adjust the state to cope with retroactive changes.” http://martinfowler.com/eaaDev/EventSourcing.html
  • 7. What is Concursus? Problems Concursus addresses: ü Processing events in a scalable and reliable way ü Processing guarantees and ordering: exactly once, out of order, repeated or missed delivery, etc.. ü Building meaningful domain models to reason about and build business logic around ü Flexibility: building additional views as needed
  • 8. Tendencies: • From internet of users to internet of things • From “presence” to “presents” • From monoliths to microservices Why Concursus?
  • 9. From Internet of Users to Internet of Things
  • 10. From Presence to Presents
  • 11. From Monoliths to Microservices
  • 12. “Write First, Reason Later” 2016-­‐10-­‐12   09:06:31.432 Received  at  Depot 2016-­‐10-­‐12   09:06:32.106 Received  at  Depot 2016-­‐10-­‐12   09:06:34.740 Received  at  Depot 2016-­‐10-­‐12   11:35:02.163 Loaded  onto  Truck 2016-­‐10-­‐12   11:40:21.032 Loaded  onto  Truck 2016-­‐10-­‐12   11:38:51.204 Loaded  onto  Truck 2016-­‐10-­‐12   14:12:44.021 Delivery  Failed 2016-­‐10-­‐12   15:00:31.322 Delivered 2016-­‐10-­‐12   15:11:05.038 Delivered
  • 14. Handling Events ü Delivery constraints out of order, repeated, delayed or missed delivery ü Processing guarantees at least once or exactly once processing, idempotency ü Ordering partial ordering across aggregates (with reasonable assumptions)
  • 15. Data Processing Layers ü Durable sufficiently durable buffer for async processing (what’s happening) ü Persistent a permanent record of everything that has happened (what happened) ü Transient fast and consistent, but also disposable state (what happens)
  • 16. Building Blocks • Java 8 and Kotlin: APIs • Cassandra: Persistent state (Event store) • Kafka: Durable state (Message broker) • Hazelcast: Transient state (cache, idempotency filters) • Also, RabbitMQ and Redis
  • 17. Sources of Inspiration Stream processing frameworks such as Apache Storm and Spark Google papers: Cloud dataflow, MillWheel Apache Spark papers The Axon CQRS framework Domain Driven Design Functional programming
  • 19. Received  at Depot Loaded  onto   Truck Delivered Delivery  Failed
  • 20. Domain Model: Events Received   at Depot Loaded   onto Truck Delivery Failed Received   at Depot Loaded   onto Truck Delivered
  • 21. aggregateType: parcel aggregateId: 69016fb5-1d69-4a34- 910b-f8ff5c702ad9 eventTimestamp: 2016-03-31 10:31:17.981 parameters: { “depotId”: “Lewisham” } Domain Model: Events Received   at Depot Loaded   onto Truck Delivery Failed Received   at Depot Loaded   onto Truck Delivered
  • 22. aggregateType: parcel aggregateId: 69016fb5-1d69-4a34- 910b-f8ff5c702ad9 eventTimestamp: 2016-03-38 08:15:23.104 parameters: { “truckId”: “J98 257” } Domain Model: Events Received   at Depot Loaded   onto Truck Delivery Failed Received   at Depot Loaded   onto Truck Delivered
  • 23. eventTimestamp: 2016-03-31T10:36:42.171Z processingTimestamp: 2016-03-31T10:36:48.3904Z parameters: { “deliveryAddress”: “123 Sudbury Avenue, Droitwich DR4 8PQ”} Domain Model: Events aggregateType: parcel aggregateId: 69016fb5-1d69-4a34- 910b-f8ff5c702ad9 Received  at  Depot Loaded  onto  Truck Delivery  Failed Received  at  Depot Loaded  onto  Truck Delivered
  • 24. Domain Model: Summary Every Event occurs to an Aggregate, identified by its type and id. Every Event has an eventTimestamp, generated by the source of the event. An Event History is a log of Events, ordered by eventTimestamp, with an additional processingTimestamp which records when the Event was captured.
  • 25. Network Event sources Event processors Events arrive: • Partitioned • Interleaved • Out-of-order Processing Model: Ordering
  • 26. Log is: • Partitioned by aggregate id • Ordered by event timestamp Processing Model: Ordering
  • 27. CREATE  TABLE  IF  NOT  EXISTS  concursus.Event ( aggregateType text, aggregateId text, eventTimestamp timestamp, streamId text, processingId timeuuid, name  text, version  text, parameters  map<text,  text>, characteristics  int, PRIMARY  KEY((aggregateType,  aggregateId),  eventTimestamp,   streamId) )  WITH  CLUSTERING  ORDER  BY  (eventTimestamp DESC); Cassandra Schema
  • 29. Cassandra Event Store RabbitMQ Topic Downstream processing out-of-order events ordered query results Cassandra & AMQP
  • 30. Cassandra Event Store Kafka Topic Downstream processing Event store listener Publish events Log events Cassandra & Kafka
  • 31. Processing Model: Summary Events arrive partitioned, interleaved and out-of-order. Events are sorted into event histories by aggregate type and id. Events are sorted within event histories by event timestamp, not processing timestamp. Event consumers need to take into account the possibility that an event history may be incomplete at the time it is read – consider using a watermark to give incoming events time to “settle”.
  • 32. Programming Model: Core Metaphor Received   at Depot Loaded   onto Truck Delivery Failed Received   at Depot Loaded   onto Truck Delivered
  • 33. Received   at Depot Loaded   onto Truck Delivery Failed Received   at Depot Loaded   onto Truck Delivered Consumer<Event> Programming Model: Core Metaphor
  • 34. You give me a Consumer<Event>, and I send Events to it one at a time: Emitting Events
  • 35. I implement Consumer<Event>, and handle Events that are sent to me. Handling Events
  • 39. Kotlin Mapping sealed  class  ParcelEvent { class  ReceivedAtDepot(val depotId:  String):  ParcelEvent() class  LoadedOntoTruck(val truckId:  String):  ParcelEvent() class  Delivered(val destinationId:  String):  ParcelEvent() class  DeliveryFailed():  ParcelEvent() }
  • 40. Kotlin Mapping eventBus.dispatchTo(parcelId, ReceivedAtDepot(depotId =  "Lewisham Depot")  at  start, LoadedOntoLorry(lorryId =  "Truck  CU50  ZCV")  at   start.plus(2,  DAYS) )
  • 41. Kotlin Mapping fun  describeEvent(event:  ParcelEvent):  Unit  =  when  (event)  { is  ReceivedAtDepot -­‐>  println("Received  at  depot:   ${event.depotId}") is  LoadedOntoTruck -­‐>  println("Loaded  onto  truck:   ${event.truckId}") is  Delivered  -­‐>  println("Delivered  to:   ${event.destinationId}") is  DeliveryFailed -­‐>  println("Delivery  failed") }
  • 42. Event-handling middleware is a chain of Consumer<Event>s that transforms, routes, persists and dispatches events. A single event submitted to this chain may be: ■ Checked against an idempotency filter (e.g. a Hazelcast distributed cache) ■ Serialised to JSON ■ Written to a message queue topic ■ Retrieved from the topic and deserialised ■ Persisted to an event store (e.g. Cassandra) ■ Published to an event handler which maintains a query-optimised view of part of the system ■ Published to an event handler which maintains an index of aggregates by event property values (e.g. lightbulbs by wattage) Event-Handling Middleware
  • 43. • Kafka Streams • Narrative threads across event histories • Generic Attribute indexing • State management and caching • Improved cloud tooling Future Directions
  • 44. Thank you for listening Any questions?