SlideShare a Scribd company logo
Events & Microservices
Saul	
  Caganoff,	
  CTO	
  Sixtree
saul@sixtree.com.au
@scaganoff
Introduction
• Asynchrony	
  is	
  considered	
  a	
  microservice	
  
characteristic
– But	
  not	
  often	
  discussed
• In	
  the	
  top	
  20	
  Google	
  results
– 7	
  mentioned	
  async/choreography	
  or	
  events
– 3	
  of	
  those	
  by	
  Chris	
  Richardson	
  or	
  Martin	
  Fowler
• Mostly	
  mentioned	
  in	
  passing
• Honourable	
  Mentions:
– http://www.infoq.com/articles/microservices-­‐intro
– http://highscalability.com/blog/2014/4/8/microservices-­‐not-­‐a-­‐free-­‐
lunch.html
WHY EVENTS?
Bounded Contexts
Finance
Sales
Fulfilment
Product
Online	
  bookstore	
  is	
  
the	
  “Hello	
  World”	
  of	
  
enterprise	
  systems
http://maribyrnong.com.au
Sales Context
Wishlist
Book
ISBN
Title
Author
Price
Order
Status
Timestamp
Sub-­‐total
GST
Total
Item
Quantity
History
Customer
Name
Age
Loyalty	
  Status
Finance Context
Wishlist
Book
ISBN
Title
Author
Price
Order
Status
Timestamp
Sub-­‐total
GST
Total
Item
Quantity
History
Customer
Name
Age
Loyalty	
  Status
Credit	
  Card
Holder	
  Name
Number
Expiry
Code
Fulfilment Context
Book
ISBN
Title
Customer
Name
Receipt
Order	
  Number
Sub-­‐total
GST
Total
Address
Street	
  Number
Street	
  Name
Suburb
Postcode
Courier
Depot
Location
Driver
Shipment
Dispatch	
  Time
ETA
Location
Product Context
Book Description
Abstract
Picture
Review
Author
Name
Biography
Inventory
Location
Quantity
ISBN
Title
Price
Coupling & Cohesion
• Cohesion – how	
  well	
  a	
  subsystem	
  forms	
  a	
  
uniting	
  whole
– How	
  well	
  a	
  bounded	
  context	
  does	
  its	
  job
• Coupling – the	
  propensity	
  for	
  change	
  in	
  one	
  
part	
  of	
  a	
  system	
  to	
  disrupt	
  another
– how	
  badly	
  “stuff”	
  leaks	
  across	
  the	
  boundaries
• Coupling	
  is	
  evil	
  – it	
  sneaks	
  into	
  solutions	
  in	
  all	
  
kinds	
  of	
  insidious	
  ways
Coupling & Cohesion
• Microservices strive to	
  eliminate	
  coupling
• Insidious	
  sources	
  of	
  coupling
– Shared	
  databases
– Single	
  Common	
  Data	
  Model	
  (vs	
  bounded	
  contexts)
– DRY	
  – shared	
  code
– APIs	
  generated	
  from	
  code
– Autogenerated client	
  SDKs
– Projects	
  – funding	
  and	
  scope
– Assumptions	
  about	
  business	
  processes
– Organizational	
  structure
Business Processes
• End-­‐to-­‐end	
  business	
  processes	
  require	
  
coordination	
  across	
  bounded	
  contexts
Finance
Sales
Ful-­‐
filment
Product
Business Processes
• Browse	
  the	
  inventory
• Create	
  order
• Enter	
  Shipping	
  Details
• Quote	
  shipping	
  charge
• Make	
  the	
  payment
• Update	
  inventory
• Create	
  Shipment
• Pick	
  &	
  Pack
• Courier
• Accept	
  delivery
GET	
  /products
POST	
  /order
PUT	
  /order/:id/address
GET	
  /3pl/charges?zip=…
POST	
  /finance/payment?order=
POST	
  /products
POST	
  /3pl/shipment
GET	
  /3pl/shipment/:id
GET	
  /3pl/shipment/:id/address
PUT	
  /3pl/shipment/:id?status=
Business Processes
• Orchestration	
  
– Centralized	
  coordination
– E.g.	
  the	
  user-­‐agent,	
  BPM	
  engine,	
  service	
  facade
– the	
  “god”	
  object
• Hypermedia
– HATEOAS
– But	
  what	
  about	
  at	
  the	
  edges?
– How	
  much	
  should	
  one	
  BC	
  know	
  about	
  another	
  BC?
“microservices architecture	
  will	
  never	
  be	
  SOA	
  done	
  right	
  unless	
  it	
  means	
  building	
  
hypermedia	
  systems	
  of	
  microservices”	
  – Jason	
  Bloomberg
http://intellyx.com/2015/07/20/are-­‐microservices-­‐soa-­‐done-­‐right/
Some Perspective
0
2
4
6
8
10
12
DB	
  Triggers Monolith Orchestration Hypermedia EDA
Coupling
Data Synchronization
• How	
  to	
  handle	
  data	
  “owned”	
  by	
  multiple	
  
domains
– Glibness: “don’t”	
  have	
  multiple	
  data	
  owners
– …in	
  reality	
  it	
  is	
  impossible	
  to	
  eliminate
– …especially	
  if	
  legacy	
  or	
  COTS	
  systems	
  involved.
• Some	
  data	
  synchronization	
  is	
  naturally	
  
conveyed	
  by	
  the	
  business	
  process
• …some	
  is	
  not.
Choreography
• Use	
  events	
  to	
  coordinate	
  activity	
  across	
  bounded	
  
contexts
• Publishers	
  &	
  Subscribers	
  are	
  highly	
  decoupled
– Event	
  subscribers	
  can	
  come	
  &	
  go	
  minimal	
  or	
  no	
  code	
  
or	
  configuration	
  changes
• Publishers	
  &	
  Subscribers	
  are	
  more	
  resilient	
  to	
  
change	
  – either	
  planned	
  or	
  unplanned
– E.g.	
  events	
  redelivered	
  in	
  the	
  event	
  of	
  subscriber	
  
failure	
  – either	
  to	
  the	
  restored	
  subscriber,	
  or	
  a	
  
replacement
Choreography
• But	
  trade-­‐offs
• Asynchronous	
  events	
  lie	
  at	
  the	
  heart	
  of	
  some	
  of	
  
the	
  microservices challenges
– Centralised	
  orchestration	
  is	
  harder	
  to	
  change,	
  but	
  
easier	
  to	
  control/monitor
– Event-­‐based	
  choreography	
  is	
  easier	
  to	
  change	
  but	
  
harder	
  to	
  control/monitor
• Distributed	
  logging/monitoring	
  systems	
  are	
  
needed	
  to	
  provide	
  a	
  view	
  into	
  asynchronous	
  
interactions
Coordination
• Think	
  about	
  hypermedia	
  inside	
  boundaries
• Events	
  outside	
  the	
  boundaries
Finance
Sales
Ful-­‐
filment
Product
MODELLING EVENTS
Commands & Events
• Duality	
  between	
  commands	
  &	
  events
– Commands	
  cause	
  state	
  transitions
– Events	
  reflect	
  state	
  transitions
• An	
  external	
  observer	
  can	
  infer	
  the	
  state	
  of	
  a	
  
resource	
  from	
  its	
  event-­‐stream
– This	
  is	
  the	
  essence	
  of	
  event-­‐sourcing	
  &	
  CQRS
State Modelling
Empty
Cart
Full
Cart
Quoted
Paid
POST	
  /cart
PUT	
  /cart/:id
{	
  book:	
  …	
  }
PUT	
  /cart/:id
{	
  book:	
  …	
  }
DELETE	
  /cart/:id/books/:id
PUT	
  /cart/:id
{	
  address:	
  …	
  }
POST	
  /payments
{	
  cart:	
  …,	
  card:	
  {…}}
Commands	
  (HATEOAS)
{create:	
  {	
  cart:	
  …	
  }	
  …	
  }
{add:	
  {	
  cart:	
  …,	
  book:	
  {…}}	
  ..}
{add:	
  {	
  cart:	
  …,	
  book:	
  {…}}	
  ..}
{del:	
  {	
  cart:	
  …,	
  book:	
  {…}}	
  ..}
{quoted:	
  {	
  cart:	
  …	
  }	
  …	
  }
{paid:	
  {	
  cart:	
  …	
  }	
  …	
  }
Events	
  (EATNOAS)
Commands & Events
Finance
Sales
Ful-­‐
filment
Product
Inventory
Marketing
Commands
Events
Reporting
Logistics
Event Structure
• Immutable	
  structures
• Typical	
  properties
– Timestamp
– Source
– Entity	
  URI
– Action	
  (state	
  transition)
• The	
  MVP	
  is	
  to	
  notify	
  that	
  a	
  resource	
  has	
  
changed	
  and	
  allow	
  subscribers	
  to	
  pull	
  the	
  
update	
  if	
  needed.
Concurrency
• Race	
  Conditions
• The	
  importance	
  of	
  order
• Single	
  Master	
  vs	
  Multi-­‐Master
• Deltas	
  vs	
  Copies
• Action	
  indicators
• CRDTs	
  – conflict-­‐free	
  replicated	
  data	
  types
• …think	
  in	
  terms	
  of	
  events	
  rather	
  than	
  copies
EVENT TRANSPORTS
Syndication
• Service	
  exposes	
  an	
  RSS/atom	
  feed
• Consumers	
  do	
  all	
  the	
  hard	
  work:
– Subscription
– State	
  Management	
  (where	
  am	
  I	
  up	
  to?)
– Retries
• Positives
– Very	
  easy…well-­‐known	
  pattern
– Web-­‐scale
• Negatives
– Polling
– High	
  latency
Web Hooks
• Service	
  POSTs	
  events	
  to	
  subscribers
• Publishers	
  do	
  all	
  the	
  hard	
  work:
– Manage	
  subscribers
– Managed	
  guaranteed	
  delivery/	
  retries
• Positives
– Not	
  polling,	
  relatively	
  lower	
  latency
• Negatives
– Subscription	
  management	
  &	
  guaranteed	
  delivery	
  
must	
  be	
  done	
  yourself…can	
  be	
  tricky.
Message Queues
• Events	
  published	
  to	
  queues/topics
– E.g JMS,	
  AMQP,	
  ZMQ,	
  SQS/SNS,	
  IronMQ
• Positives
– Mature,	
  well-­‐known	
  technologies
– Good	
  open-­‐source	
  implementations	
  available
– Competing	
  consumer	
  pattern
• Negatives
– Extra	
  infrastructure
– Reliability	
  depends	
  on	
  reliable	
  file-­‐systems	
  
• SANs,	
  Distributed	
  file-­‐lock	
  managers
Apache Kafka
• Distributed	
  log
• Similar	
  model	
  to	
  syndication
– Single	
  node	
  shares	
  data	
  by	
  writing	
  to	
  logfiles
– Consumers	
  tail	
  the	
  logs
• Consumers	
  control	
  their	
  position	
  in	
  the	
  log
• Low	
  latency
• Reliability	
  handled	
  at	
  the	
  application	
  layer
– whether	
  Zookeeper	
  is	
  less	
  burdensome	
  than	
  clustered	
  
file	
  system	
  is	
  up	
  to	
  you
Event Processing
• Simple	
  events	
  are	
  very	
  useful	
  for	
  data	
  
synchronization	
  or	
  process	
  coordination
• Continuum	
  of	
  complexity
• Some	
  tools:	
  Drools,	
  Riemann.io,	
  Apache	
  Storm
• This	
  is	
  a	
  whole	
  ‘nother topic
Cardinality State Tools
Single	
  event Simple Event	
  processor
Multiple	
  events/stream Simple Stream	
  processor
Multiple	
  events/stream Complex	
  /	
  Rules Complex	
  Event	
  Processor
Wrap-Up
• Bounded	
  contexts	
  are	
  important
– they	
  promote	
  cohesion	
  and	
  reduce	
  coupling
• You	
  need	
  to	
  decide	
  how	
  to	
  coordinate	
  data	
  &	
  
processes	
  across	
  boundaries
– Orchestration	
  (relatively	
  higher	
  coupling)
– Hypermedia	
  (couples	
  across	
  boundaries)
– Events
• Prefer	
  Hypermedia	
  within	
  bounded	
  contexts	
  &	
  events	
  
across	
  bounded	
  contexts
Events	
  have	
  many	
  benefits	
  but	
  also	
  some	
  downsides	
  -­‐
they	
  are	
  an	
  important	
  tool	
  in	
  your	
  toolbox.

More Related Content

What's hot

Gartner event mesh solace - phil scanlon - gold coast
Gartner event mesh   solace - phil scanlon - gold coastGartner event mesh   solace - phil scanlon - gold coast
Gartner event mesh solace - phil scanlon - gold coast
Phil Scanlon
 
Using Kafka in Your Organization with Real-Time User Insights for a Customer ...
Using Kafka in Your Organization with Real-Time User Insights for a Customer ...Using Kafka in Your Organization with Real-Time User Insights for a Customer ...
Using Kafka in Your Organization with Real-Time User Insights for a Customer ...
confluent
 
WJAX 2013 Slides online: Big Data beyond Apache Hadoop - How to integrate ALL...
WJAX 2013 Slides online: Big Data beyond Apache Hadoop - How to integrate ALL...WJAX 2013 Slides online: Big Data beyond Apache Hadoop - How to integrate ALL...
WJAX 2013 Slides online: Big Data beyond Apache Hadoop - How to integrate ALL...
Kai Wähner
 
Data center world 2010 10 5 10
Data center world 2010   10 5 10Data center world 2010   10 5 10
Data center world 2010 10 5 10
David Resnic
 
Event-driven Business: How Leading Companies Are Adopting Streaming Strategies
Event-driven Business: How Leading Companies Are Adopting Streaming StrategiesEvent-driven Business: How Leading Companies Are Adopting Streaming Strategies
Event-driven Business: How Leading Companies Are Adopting Streaming Strategies
confluent
 
Fast Data for Competitive Advantage: 4 Steps to Expand your Window of Opportu...
Fast Data for Competitive Advantage: 4 Steps to Expand your Window of Opportu...Fast Data for Competitive Advantage: 4 Steps to Expand your Window of Opportu...
Fast Data for Competitive Advantage: 4 Steps to Expand your Window of Opportu...
VoltDB
 
Analytics Patterns for Your Digital Enterprise
Analytics Patterns for Your Digital EnterpriseAnalytics Patterns for Your Digital Enterprise
Analytics Patterns for Your Digital Enterprise
Sriskandarajah Suhothayan
 
Analyzing Billions of Data Rows with Alteryx, Amazon Redshift, and Tableau
Analyzing Billions of Data Rows with Alteryx, Amazon Redshift, and TableauAnalyzing Billions of Data Rows with Alteryx, Amazon Redshift, and Tableau
Analyzing Billions of Data Rows with Alteryx, Amazon Redshift, and Tableau
DATAVERSITY
 
The Streaming Assessment – An Introduction
The Streaming Assessment – An IntroductionThe Streaming Assessment – An Introduction
The Streaming Assessment – An Introduction
confluent
 
Lighning Talk: Event-Driven architecture for microservices
Lighning Talk: Event-Driven architecture for microservicesLighning Talk: Event-Driven architecture for microservices
Lighning Talk: Event-Driven architecture for microservices
Martins Sipenko
 
WSO2Con USA 2017: Driving Insights for Your Digital Business With Analytics
WSO2Con USA 2017: Driving Insights for Your Digital Business With AnalyticsWSO2Con USA 2017: Driving Insights for Your Digital Business With Analytics
WSO2Con USA 2017: Driving Insights for Your Digital Business With Analytics
WSO2
 
Hybrid & Global Kafka Architecture
Hybrid & Global Kafka ArchitectureHybrid & Global Kafka Architecture
Hybrid & Global Kafka Architecture
confluent
 
Event-Driven Microservices with Apache Kafka, Kafka Streams and KSQL
Event-Driven Microservices with Apache Kafka, Kafka Streams and KSQLEvent-Driven Microservices with Apache Kafka, Kafka Streams and KSQL
Event-Driven Microservices with Apache Kafka, Kafka Streams and KSQL
Kai Wähner
 
Event Streaming in Retail with Apache Kafka
Event Streaming in Retail with Apache KafkaEvent Streaming in Retail with Apache Kafka
Event Streaming in Retail with Apache Kafka
Kai Wähner
 
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Kai Wähner
 
Confluent & MongoDB APAC Lunch & Learn
Confluent & MongoDB APAC Lunch & LearnConfluent & MongoDB APAC Lunch & Learn
Confluent & MongoDB APAC Lunch & Learn
confluent
 
Apache Kafka Landscape for Automotive and Manufacturing
Apache Kafka Landscape for Automotive and ManufacturingApache Kafka Landscape for Automotive and Manufacturing
Apache Kafka Landscape for Automotive and Manufacturing
Kai Wähner
 
Data reply sneak peek: real time decision engines
Data reply sneak peek:  real time decision enginesData reply sneak peek:  real time decision engines
Data reply sneak peek: real time decision engines
confluent
 
Connecting Apache Kafka to Cash
Connecting Apache Kafka to CashConnecting Apache Kafka to Cash
Connecting Apache Kafka to Cash
confluent
 
Apache Kafka for Automotive Industry, Mobility Services & Smart City
Apache Kafka for Automotive Industry, Mobility Services & Smart CityApache Kafka for Automotive Industry, Mobility Services & Smart City
Apache Kafka for Automotive Industry, Mobility Services & Smart City
Kai Wähner
 

What's hot (20)

Gartner event mesh solace - phil scanlon - gold coast
Gartner event mesh   solace - phil scanlon - gold coastGartner event mesh   solace - phil scanlon - gold coast
Gartner event mesh solace - phil scanlon - gold coast
 
Using Kafka in Your Organization with Real-Time User Insights for a Customer ...
Using Kafka in Your Organization with Real-Time User Insights for a Customer ...Using Kafka in Your Organization with Real-Time User Insights for a Customer ...
Using Kafka in Your Organization with Real-Time User Insights for a Customer ...
 
WJAX 2013 Slides online: Big Data beyond Apache Hadoop - How to integrate ALL...
WJAX 2013 Slides online: Big Data beyond Apache Hadoop - How to integrate ALL...WJAX 2013 Slides online: Big Data beyond Apache Hadoop - How to integrate ALL...
WJAX 2013 Slides online: Big Data beyond Apache Hadoop - How to integrate ALL...
 
Data center world 2010 10 5 10
Data center world 2010   10 5 10Data center world 2010   10 5 10
Data center world 2010 10 5 10
 
Event-driven Business: How Leading Companies Are Adopting Streaming Strategies
Event-driven Business: How Leading Companies Are Adopting Streaming StrategiesEvent-driven Business: How Leading Companies Are Adopting Streaming Strategies
Event-driven Business: How Leading Companies Are Adopting Streaming Strategies
 
Fast Data for Competitive Advantage: 4 Steps to Expand your Window of Opportu...
Fast Data for Competitive Advantage: 4 Steps to Expand your Window of Opportu...Fast Data for Competitive Advantage: 4 Steps to Expand your Window of Opportu...
Fast Data for Competitive Advantage: 4 Steps to Expand your Window of Opportu...
 
Analytics Patterns for Your Digital Enterprise
Analytics Patterns for Your Digital EnterpriseAnalytics Patterns for Your Digital Enterprise
Analytics Patterns for Your Digital Enterprise
 
Analyzing Billions of Data Rows with Alteryx, Amazon Redshift, and Tableau
Analyzing Billions of Data Rows with Alteryx, Amazon Redshift, and TableauAnalyzing Billions of Data Rows with Alteryx, Amazon Redshift, and Tableau
Analyzing Billions of Data Rows with Alteryx, Amazon Redshift, and Tableau
 
The Streaming Assessment – An Introduction
The Streaming Assessment – An IntroductionThe Streaming Assessment – An Introduction
The Streaming Assessment – An Introduction
 
Lighning Talk: Event-Driven architecture for microservices
Lighning Talk: Event-Driven architecture for microservicesLighning Talk: Event-Driven architecture for microservices
Lighning Talk: Event-Driven architecture for microservices
 
WSO2Con USA 2017: Driving Insights for Your Digital Business With Analytics
WSO2Con USA 2017: Driving Insights for Your Digital Business With AnalyticsWSO2Con USA 2017: Driving Insights for Your Digital Business With Analytics
WSO2Con USA 2017: Driving Insights for Your Digital Business With Analytics
 
Hybrid & Global Kafka Architecture
Hybrid & Global Kafka ArchitectureHybrid & Global Kafka Architecture
Hybrid & Global Kafka Architecture
 
Event-Driven Microservices with Apache Kafka, Kafka Streams and KSQL
Event-Driven Microservices with Apache Kafka, Kafka Streams and KSQLEvent-Driven Microservices with Apache Kafka, Kafka Streams and KSQL
Event-Driven Microservices with Apache Kafka, Kafka Streams and KSQL
 
Event Streaming in Retail with Apache Kafka
Event Streaming in Retail with Apache KafkaEvent Streaming in Retail with Apache Kafka
Event Streaming in Retail with Apache Kafka
 
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
Architecture patterns for distributed, hybrid, edge and global Apache Kafka d...
 
Confluent & MongoDB APAC Lunch & Learn
Confluent & MongoDB APAC Lunch & LearnConfluent & MongoDB APAC Lunch & Learn
Confluent & MongoDB APAC Lunch & Learn
 
Apache Kafka Landscape for Automotive and Manufacturing
Apache Kafka Landscape for Automotive and ManufacturingApache Kafka Landscape for Automotive and Manufacturing
Apache Kafka Landscape for Automotive and Manufacturing
 
Data reply sneak peek: real time decision engines
Data reply sneak peek:  real time decision enginesData reply sneak peek:  real time decision engines
Data reply sneak peek: real time decision engines
 
Connecting Apache Kafka to Cash
Connecting Apache Kafka to CashConnecting Apache Kafka to Cash
Connecting Apache Kafka to Cash
 
Apache Kafka for Automotive Industry, Mobility Services & Smart City
Apache Kafka for Automotive Industry, Mobility Services & Smart CityApache Kafka for Automotive Industry, Mobility Services & Smart City
Apache Kafka for Automotive Industry, Mobility Services & Smart City
 

Viewers also liked

Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud FoundryConcevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
VMware Tanzu
 
What's new in Pivotal Cloud Foundry 1.6
What's new in Pivotal Cloud Foundry 1.6What's new in Pivotal Cloud Foundry 1.6
What's new in Pivotal Cloud Foundry 1.6
dektlong
 
Neuro4j Workflow Overview
Neuro4j Workflow OverviewNeuro4j Workflow Overview
Neuro4j Workflow Overview
Dmytro Pavlikovskiy
 
Breaking the Monolith
Breaking the MonolithBreaking the Monolith
Breaking the Monolith
VMware Tanzu
 
Building microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring BootBuilding microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring Boot
Chris Richardson
 
The Journey from Monolith to Microservices: a Guided Adventure
The Journey from Monolith to Microservices: a Guided AdventureThe Journey from Monolith to Microservices: a Guided Adventure
The Journey from Monolith to Microservices: a Guided Adventure
VMware Tanzu
 
The Cloud Native Journey
The Cloud Native JourneyThe Cloud Native Journey
The Cloud Native Journey
VMware Tanzu
 

Viewers also liked (7)

Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud FoundryConcevoir et déployer vos applications a base de microservices sur Cloud Foundry
Concevoir et déployer vos applications a base de microservices sur Cloud Foundry
 
What's new in Pivotal Cloud Foundry 1.6
What's new in Pivotal Cloud Foundry 1.6What's new in Pivotal Cloud Foundry 1.6
What's new in Pivotal Cloud Foundry 1.6
 
Neuro4j Workflow Overview
Neuro4j Workflow OverviewNeuro4j Workflow Overview
Neuro4j Workflow Overview
 
Breaking the Monolith
Breaking the MonolithBreaking the Monolith
Breaking the Monolith
 
Building microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring BootBuilding microservices with Scala, functional domain models and Spring Boot
Building microservices with Scala, functional domain models and Spring Boot
 
The Journey from Monolith to Microservices: a Guided Adventure
The Journey from Monolith to Microservices: a Guided AdventureThe Journey from Monolith to Microservices: a Guided Adventure
The Journey from Monolith to Microservices: a Guided Adventure
 
The Cloud Native Journey
The Cloud Native JourneyThe Cloud Native Journey
The Cloud Native Journey
 

Similar to Events and microservices

Events & Microservices
Events & MicroservicesEvents & Microservices
Events & Microservices
Yamen Sader
 
Moving To MicroServices
Moving To MicroServicesMoving To MicroServices
Moving To MicroServices
David Walker
 
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
confluent
 
Introduction to Stream Processing
Introduction to Stream ProcessingIntroduction to Stream Processing
Introduction to Stream Processing
Guido Schmutz
 
Stream Processing in Action
Stream Processing in ActionStream Processing in Action
Stream Processing in Action
WSO2
 
Understanding event data
Understanding event dataUnderstanding event data
Understanding event data
yalisassoon
 
WebAction In-Memory Computing Summit 2015
WebAction In-Memory Computing Summit 2015WebAction In-Memory Computing Summit 2015
WebAction In-Memory Computing Summit 2015
WebAction
 
Smart Process Automation - Connected Brains 2018
Smart Process Automation - Connected Brains 2018Smart Process Automation - Connected Brains 2018
Smart Process Automation - Connected Brains 2018
LoQutus
 
Kafka-and-event-driven-architecture-OGYatra20.ppt
Kafka-and-event-driven-architecture-OGYatra20.pptKafka-and-event-driven-architecture-OGYatra20.ppt
Kafka-and-event-driven-architecture-OGYatra20.ppt
Inam Bukhary
 
BigData & CDN - OOP2011 (Pavlo Baron)
BigData & CDN - OOP2011 (Pavlo Baron)BigData & CDN - OOP2011 (Pavlo Baron)
BigData & CDN - OOP2011 (Pavlo Baron)
Pavlo Baron
 
ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...
ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...
ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...
OpenCredo
 
Kalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge ContinuumKalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge Continuum
Jonas Bonér
 
How to Realize the Benefits of Cloud Services Brokerage
How to Realize the Benefits of Cloud Services BrokerageHow to Realize the Benefits of Cloud Services Brokerage
How to Realize the Benefits of Cloud Services Brokerage
jamcracker4677
 
Resource-Oriented Architecture (ROA)
Resource-Oriented Architecture (ROA)Resource-Oriented Architecture (ROA)
Resource-Oriented Architecture (ROA)
WSO2
 
Extending your applications to the edge with CDNs
Extending your applications to the edge with CDNsExtending your applications to the edge with CDNs
Extending your applications to the edge with CDNs
SergeyChernyshev
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20
Vinay Kumar
 
Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20
Vinay Kumar
 
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
confluent
 
Responsive Innovation in a Local Context
Responsive Innovation in a Local ContextResponsive Innovation in a Local Context
Responsive Innovation in a Local Context
Paul Walk
 
Message Driven and Event Sourcing
Message Driven and Event SourcingMessage Driven and Event Sourcing
Message Driven and Event Sourcing
Paolo Castagna
 

Similar to Events and microservices (20)

Events & Microservices
Events & MicroservicesEvents & Microservices
Events & Microservices
 
Moving To MicroServices
Moving To MicroServicesMoving To MicroServices
Moving To MicroServices
 
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
Event Sourcing, Stream Processing and Serverless (Benjamin Stopford, Confluen...
 
Introduction to Stream Processing
Introduction to Stream ProcessingIntroduction to Stream Processing
Introduction to Stream Processing
 
Stream Processing in Action
Stream Processing in ActionStream Processing in Action
Stream Processing in Action
 
Understanding event data
Understanding event dataUnderstanding event data
Understanding event data
 
WebAction In-Memory Computing Summit 2015
WebAction In-Memory Computing Summit 2015WebAction In-Memory Computing Summit 2015
WebAction In-Memory Computing Summit 2015
 
Smart Process Automation - Connected Brains 2018
Smart Process Automation - Connected Brains 2018Smart Process Automation - Connected Brains 2018
Smart Process Automation - Connected Brains 2018
 
Kafka-and-event-driven-architecture-OGYatra20.ppt
Kafka-and-event-driven-architecture-OGYatra20.pptKafka-and-event-driven-architecture-OGYatra20.ppt
Kafka-and-event-driven-architecture-OGYatra20.ppt
 
BigData & CDN - OOP2011 (Pavlo Baron)
BigData & CDN - OOP2011 (Pavlo Baron)BigData & CDN - OOP2011 (Pavlo Baron)
BigData & CDN - OOP2011 (Pavlo Baron)
 
ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...
ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...
ThingMonk 2016 - Concursus Event sourcing for the IOT By Tareq Abedrabbo & Do...
 
Kalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge ContinuumKalix: Tackling the The Cloud to Edge Continuum
Kalix: Tackling the The Cloud to Edge Continuum
 
How to Realize the Benefits of Cloud Services Brokerage
How to Realize the Benefits of Cloud Services BrokerageHow to Realize the Benefits of Cloud Services Brokerage
How to Realize the Benefits of Cloud Services Brokerage
 
Resource-Oriented Architecture (ROA)
Resource-Oriented Architecture (ROA)Resource-Oriented Architecture (ROA)
Resource-Oriented Architecture (ROA)
 
Extending your applications to the edge with CDNs
Extending your applications to the edge with CDNsExtending your applications to the edge with CDNs
Extending your applications to the edge with CDNs
 
Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20Kafka and event driven architecture -apacoug20
Kafka and event driven architecture -apacoug20
 
Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20Kafka and event driven architecture -og yatra20
Kafka and event driven architecture -og yatra20
 
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
Event Driven Architecture with a RESTful Microservices Architecture (Kyle Ben...
 
Responsive Innovation in a Local Context
Responsive Innovation in a Local ContextResponsive Innovation in a Local Context
Responsive Innovation in a Local Context
 
Message Driven and Event Sourcing
Message Driven and Event SourcingMessage Driven and Event Sourcing
Message Driven and Event Sourcing
 

Recently uploaded

zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 

Recently uploaded (20)

zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 

Events and microservices

  • 1. Events & Microservices Saul  Caganoff,  CTO  Sixtree saul@sixtree.com.au @scaganoff
  • 2. Introduction • Asynchrony  is  considered  a  microservice   characteristic – But  not  often  discussed • In  the  top  20  Google  results – 7  mentioned  async/choreography  or  events – 3  of  those  by  Chris  Richardson  or  Martin  Fowler • Mostly  mentioned  in  passing • Honourable  Mentions: – http://www.infoq.com/articles/microservices-­‐intro – http://highscalability.com/blog/2014/4/8/microservices-­‐not-­‐a-­‐free-­‐ lunch.html
  • 4. Bounded Contexts Finance Sales Fulfilment Product Online  bookstore  is   the  “Hello  World”  of   enterprise  systems http://maribyrnong.com.au
  • 7. Fulfilment Context Book ISBN Title Customer Name Receipt Order  Number Sub-­‐total GST Total Address Street  Number Street  Name Suburb Postcode Courier Depot Location Driver Shipment Dispatch  Time ETA Location
  • 9. Coupling & Cohesion • Cohesion – how  well  a  subsystem  forms  a   uniting  whole – How  well  a  bounded  context  does  its  job • Coupling – the  propensity  for  change  in  one   part  of  a  system  to  disrupt  another – how  badly  “stuff”  leaks  across  the  boundaries • Coupling  is  evil  – it  sneaks  into  solutions  in  all   kinds  of  insidious  ways
  • 10.
  • 11. Coupling & Cohesion • Microservices strive to  eliminate  coupling • Insidious  sources  of  coupling – Shared  databases – Single  Common  Data  Model  (vs  bounded  contexts) – DRY  – shared  code – APIs  generated  from  code – Autogenerated client  SDKs – Projects  – funding  and  scope – Assumptions  about  business  processes – Organizational  structure
  • 12. Business Processes • End-­‐to-­‐end  business  processes  require   coordination  across  bounded  contexts Finance Sales Ful-­‐ filment Product
  • 13. Business Processes • Browse  the  inventory • Create  order • Enter  Shipping  Details • Quote  shipping  charge • Make  the  payment • Update  inventory • Create  Shipment • Pick  &  Pack • Courier • Accept  delivery GET  /products POST  /order PUT  /order/:id/address GET  /3pl/charges?zip=… POST  /finance/payment?order= POST  /products POST  /3pl/shipment GET  /3pl/shipment/:id GET  /3pl/shipment/:id/address PUT  /3pl/shipment/:id?status=
  • 14. Business Processes • Orchestration   – Centralized  coordination – E.g.  the  user-­‐agent,  BPM  engine,  service  facade – the  “god”  object • Hypermedia – HATEOAS – But  what  about  at  the  edges? – How  much  should  one  BC  know  about  another  BC? “microservices architecture  will  never  be  SOA  done  right  unless  it  means  building   hypermedia  systems  of  microservices”  – Jason  Bloomberg http://intellyx.com/2015/07/20/are-­‐microservices-­‐soa-­‐done-­‐right/
  • 15. Some Perspective 0 2 4 6 8 10 12 DB  Triggers Monolith Orchestration Hypermedia EDA Coupling
  • 16. Data Synchronization • How  to  handle  data  “owned”  by  multiple   domains – Glibness: “don’t”  have  multiple  data  owners – …in  reality  it  is  impossible  to  eliminate – …especially  if  legacy  or  COTS  systems  involved. • Some  data  synchronization  is  naturally   conveyed  by  the  business  process • …some  is  not.
  • 17. Choreography • Use  events  to  coordinate  activity  across  bounded   contexts • Publishers  &  Subscribers  are  highly  decoupled – Event  subscribers  can  come  &  go  minimal  or  no  code   or  configuration  changes • Publishers  &  Subscribers  are  more  resilient  to   change  – either  planned  or  unplanned – E.g.  events  redelivered  in  the  event  of  subscriber   failure  – either  to  the  restored  subscriber,  or  a   replacement
  • 18. Choreography • But  trade-­‐offs • Asynchronous  events  lie  at  the  heart  of  some  of   the  microservices challenges – Centralised  orchestration  is  harder  to  change,  but   easier  to  control/monitor – Event-­‐based  choreography  is  easier  to  change  but   harder  to  control/monitor • Distributed  logging/monitoring  systems  are   needed  to  provide  a  view  into  asynchronous   interactions
  • 19. Coordination • Think  about  hypermedia  inside  boundaries • Events  outside  the  boundaries Finance Sales Ful-­‐ filment Product
  • 21. Commands & Events • Duality  between  commands  &  events – Commands  cause  state  transitions – Events  reflect  state  transitions • An  external  observer  can  infer  the  state  of  a   resource  from  its  event-­‐stream – This  is  the  essence  of  event-­‐sourcing  &  CQRS
  • 22. State Modelling Empty Cart Full Cart Quoted Paid POST  /cart PUT  /cart/:id {  book:  …  } PUT  /cart/:id {  book:  …  } DELETE  /cart/:id/books/:id PUT  /cart/:id {  address:  …  } POST  /payments {  cart:  …,  card:  {…}} Commands  (HATEOAS) {create:  {  cart:  …  }  …  } {add:  {  cart:  …,  book:  {…}}  ..} {add:  {  cart:  …,  book:  {…}}  ..} {del:  {  cart:  …,  book:  {…}}  ..} {quoted:  {  cart:  …  }  …  } {paid:  {  cart:  …  }  …  } Events  (EATNOAS)
  • 24. Event Structure • Immutable  structures • Typical  properties – Timestamp – Source – Entity  URI – Action  (state  transition) • The  MVP  is  to  notify  that  a  resource  has   changed  and  allow  subscribers  to  pull  the   update  if  needed.
  • 25. Concurrency • Race  Conditions • The  importance  of  order • Single  Master  vs  Multi-­‐Master • Deltas  vs  Copies • Action  indicators • CRDTs  – conflict-­‐free  replicated  data  types • …think  in  terms  of  events  rather  than  copies
  • 27. Syndication • Service  exposes  an  RSS/atom  feed • Consumers  do  all  the  hard  work: – Subscription – State  Management  (where  am  I  up  to?) – Retries • Positives – Very  easy…well-­‐known  pattern – Web-­‐scale • Negatives – Polling – High  latency
  • 28. Web Hooks • Service  POSTs  events  to  subscribers • Publishers  do  all  the  hard  work: – Manage  subscribers – Managed  guaranteed  delivery/  retries • Positives – Not  polling,  relatively  lower  latency • Negatives – Subscription  management  &  guaranteed  delivery   must  be  done  yourself…can  be  tricky.
  • 29. Message Queues • Events  published  to  queues/topics – E.g JMS,  AMQP,  ZMQ,  SQS/SNS,  IronMQ • Positives – Mature,  well-­‐known  technologies – Good  open-­‐source  implementations  available – Competing  consumer  pattern • Negatives – Extra  infrastructure – Reliability  depends  on  reliable  file-­‐systems   • SANs,  Distributed  file-­‐lock  managers
  • 30. Apache Kafka • Distributed  log • Similar  model  to  syndication – Single  node  shares  data  by  writing  to  logfiles – Consumers  tail  the  logs • Consumers  control  their  position  in  the  log • Low  latency • Reliability  handled  at  the  application  layer – whether  Zookeeper  is  less  burdensome  than  clustered   file  system  is  up  to  you
  • 31. Event Processing • Simple  events  are  very  useful  for  data   synchronization  or  process  coordination • Continuum  of  complexity • Some  tools:  Drools,  Riemann.io,  Apache  Storm • This  is  a  whole  ‘nother topic Cardinality State Tools Single  event Simple Event  processor Multiple  events/stream Simple Stream  processor Multiple  events/stream Complex  /  Rules Complex  Event  Processor
  • 32. Wrap-Up • Bounded  contexts  are  important – they  promote  cohesion  and  reduce  coupling • You  need  to  decide  how  to  coordinate  data  &   processes  across  boundaries – Orchestration  (relatively  higher  coupling) – Hypermedia  (couples  across  boundaries) – Events • Prefer  Hypermedia  within  bounded  contexts  &  events   across  bounded  contexts Events  have  many  benefits  but  also  some  downsides  -­‐ they  are  an  important  tool  in  your  toolbox.