SlideShare a Scribd company logo
1 of 51
Download to read offline
Microservices – Event Driven Systems
Arnaud Bouchez - Synopse
MICROSERVICES
Event Driven Design
Microservices – Event Driven Systems
• Arnaud Bouchez
– Delphi Expert
• Various solutions (from Vatican to gaming industry)
• IoT solution (RSI)
• Real-time Monitoring solution (LiveMon)
– Open Source
• mORMot (SOA ORM MVC framework)
• SynPDF SynMustache SynDB SynCrypto
– Training and consultancy
• Synopse one-man company
Microservices – Event Driven Systems
Event-Driven Systems
• Using Events?
• Event-Driven Design
• Event-Driven mORMot
Microservices – Event Driven Systems
Using Events?
• Imperative Architecture
– Events are high-level commands
Microservices – Event Driven Systems
Using Events?
• Imperative Architecture
– Events are high-level commands
• Easy modelization into regular code
procedure TZen.HandleIAmGoingOut(Sender: TPeople);
var temp: TTemperature;
begin
temp := TemperatureSensor.GetTemperature;
if temp > Threshold then
RoboValet.FetchDownJacket(Sender);
end;
Microservices – Event Driven Systems
Using Events?
• Imperative Architecture
– State is stored in a main shared DB
– Events are high-level commands
translated into SQL statements
Microservices – Event Driven Systems
Using Events?
• Imperative Architecture
– State is stored in a main shared DB
– Events are high-level commands
translated into SQL statements
• DB-centric approach
• Atomicity is ensured, but history is lost
• DB becomes a bottleneck
Microservices – Event Driven Systems
Using Events?
• Event-Driven Architecture
– Collaboration is done using Events
Microservices – Event Driven Systems
Using Events?
• Event-Driven Architecture
– Collaboration is
done using Events
Just like
VCL/FMX /LCL !
Microservices – Event Driven Systems
Using Events?
• Event-Driven Architecture
– Collaboration is done using Events
– System consists in uncoupled nodes
which could be added or removed on-the-fly
– Nodes publish events, and subscribe to them
– Each node stores the information it needs
– Some API gateways expose state via REST
Microservices – Event Driven Systems
Event-Driven Architecture
• Nodes implemented as services
procedure TZen.Init;
begin
TemperatureSensor.SubscribeToTempChange(OnTempChanged);
end;
procedure TZen.OnTempChanged(NewTemp: TTemperature);
begin
CurrentTemp := NewTemp;
end;
procedure TZen.HandleIAmGoingOut(Sender: TPeople);
begin
if CurrentTemp > Threshold then
RoboValet.NotifyNeedsJacket(Sender);
end;
Microservices – Event Driven Systems
Event-Driven Architecture
– Collaboration is done using Events
Not natural to imperative code (Delphi, C#, Java)
– System consists in uncoupled nodes
Architecture becomes complex
– Nodes publish events, and subscribe to them
May be subject to unexpected loops
– Each node stores the information it needs
Duplicated data, with eventual consistency
Microservices – Event Driven Systems
Event-Driven Architecture
• More complex than imperative code
procedure TZen.HandleIAmGoingOut(Sender: TPeople);
var temp: TTemperature;
begin
temp := TemperatureSensor.GetTemperature;
if temp > Threshold then
RoboValet.FetchDownJacket(Sender);
end;
Microservices – Event Driven Systems
Event-Driven Architecture
• Events may be received for no use
e.g. the following method is always called
procedure TZen.OnTempChanged(NewTemp: TTemperature);
begin
CurrentTemp := NewTemp;
end;
but this value may never be used in
procedure TZen.HandleIAmGoingOut(Sender: TPeople);
begin
if CurrentTemp > Threshold then
RoboValet.NotifyNeedsJacket(Sender);
end;
Microservices – Event Driven Systems
Event-Driven Architecture
• Danger of unexpected infinite loop
procedure TZen.HandleIAmGoingOut(Sender: TPeople);
begin
if CurrentTemp > Threshold then
RoboValet.NotifyNeedsJacket(Sender);
end;
What happens
if RoboValet.NotifyNeedsJacket
triggers (indirectly) TZen.HandleIAmGoingOut ?
Since nodes may be added at any time,
how to prevent it to happen?
Microservices – Event Driven Systems
Event-Driven Architecture
• Danger of unexpected infinite loop
procedure TZen.HandleIAmGoingOut(Sender: TPeople);
begin
if CurrentTemp > Threshold then
RoboValet.NotifyNeedsJacket(Sender);
end;
What happens
if RoboValet.NotifyNeedsJacket
triggers (indirectly) TZen.HandleIAmGoingOut ?
Enter the Event-Driven debugging hell:
actual event process depends on the system it runs on
Microservices – Event Driven Systems
Event-Driven Architecture
• So, when to use it?
– Your are modeling evolving information
• e.g. scale to a lot of devices or users
– You need to track changes of state
• A monolithic DB only stores the current state
(via Update) - otherwise it may sink under Inserts
• Event-Sourcing and CQRS (see later)
Microservices – Event Driven Systems
Event-Driven Architecture
• So, when to use it?
– You expect a modular design
• Process not written in stone during compilation
(as in imperative programming): add/enable nodes
to change the system behavior at runtime
• Microservices, SaaS, horizontal scaling
Microservices – Event Driven Systems
Event-Driven Architecture
• So, when to use it?
– You defined a stateless domain
• From state comes complexity,
so DDD usually modelizes a time snapshot
• DDD events are a way to introduce temporality
– Never 100% Event-Driven
• You will eventually define REST API gateways
Microservices – Event Driven Systems
Event-Driven Architecture
• Message Bus
– Most common way to implement Event-Driven
• Cloud, Local or in-house Queues
• Like VCL TApplication.ProcessMessages
– Publish/Subscribe mechanism
• Nodes get only needed information
• Nodes could be added/removed
– Used in conjunction with regular DB and REST
Microservices – Event Driven Systems
Event-Driven Architecture
• Message Bus
Microservices – Event Driven Systems
Event-Driven Architecture
• Peer to peer communication
– Nodes communicate directly between them
• Each node manages its own queue(s)
• Good integration with REST
• Need a centralized catalog service, P2P ZeroMQ,
or convention-over-configuration setup
• As offered by mORMot over WebSockets
Microservices – Event Driven Systems
Event-Driven Architecture
• Event Sourcing
– Business logic is implemented through Events
– Events are persisted, not state
• Play the events to compute a state
• Intermediate states may be cached/persisted
– Events are transmitted, not state
• Publish/Subscribe instead of REST
• Define API gateways for the outer world
Microservices – Event Driven Systems
Event-Driven Architecture
• Event Sourcing
– Business logic is implemented through Events
– Convenient way to define Microservices
• Subscribe to events, to get the information
• Publish events, as result of the process
– Microservices persistence
• Most Microservices will use a regular state storage
• Some Microservices will use Event Sourcing
Microservices – Event Driven Systems
Event-Driven Architecture
• Events and CQRS
– Command Query Responsibility Segregation
• Commands triggers events
• Events are gathered and stored
• State/Events store is uncoupled from Commands
– CQRS follows a non CRUD pattern
• Create Read Update Delete
Microservices – Event Driven Systems
Event-Driven Architecture
• CRUD
DB
Microservices – Event Driven Systems
Event-Driven Architecture
• CQRS
DB
Microservices – Event Driven Systems
Event-Driven mORMot
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services
type
ICalculator = interface(IInvokable)
['{9A60C8ED-CEB2-4E09-87D4-4A16F496E5FE}']
/// add two signed 32 bit integers
function Add(n1,n2: integer): integer;
end;
– Defines the contract of the service
– Microservice: should follow SOLID principles
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services
procedure ResolveCalculator(out: ICalculator);
...
function TMyClient.MyAdd(a,b: integer): integer;
var Calculator: ICalculator;
begin
Client.Services.Resolve(ICalculator, Calculator);
result := Calculator.Add(a,b);
end;
– Runtime injection of the actual implementation
• May be in-process, local or remote
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services
var Calculator: ICalculator;
begin
Client.Services.Resolve(ICalculator, Calculator);
result := Calculator.Add(a,b);
end;
– Client is a mORMot TSQLRestClientURI
– Will communicate using JSON over HTTP(S)
Microservices – Event Driven Systems
Event-Driven mORMot
• RESTful Local and Client-Server
– In-process
Stand-alone client, fast server-side access
– Named pipes or Windows messages
Stand-alone client, fast server-side access
– HTTP/1.1 via kernel-mode http.sys API
• Kernel-mode execution, IOCP driven, https – Windows specific
– HTTP/1.1 via OS socket API
• Windows or Linux, using a Thread Pool, https via Reverse Proxy
• Upgradable to WebSockets
Microservices – Event Driven Systems
Event-Driven mORMot
• RESTful Client
TSQLRestServer
TSQLRest
TSQLRestClientURI
TSQLRestClient
Microservices – Event Driven Systems
Event-Driven mORMot
• RESTful Server
TSQLRestServerDB
TSQLRestServer
TSQLRest
TSQLRestServerRemoteDB TSQLRestServerFullMemory
Microservices – Event Driven Systems
Event-Driven mORMot
• RESTful Local and Client-Server
– Needed methods are available at TSQLRest
• REST auto-routing
• JSON high-performance serialization
• Following Liskov Substitution Principle
– Focus on the logic
– Abstract from the plumbing
Microservices – Event Driven Systems
Event-Driven mORMot
• REST/JSON Persistence via ORM/ODM
– Agnostic Storage for Events or State
• ORM over local SQlite3 store
• ORM over remote SQL databases
• ODM over TObjectList
• ODM over MongoDB
Switching from one to another
in a few lines of code, or through settings
Microservices – Event Driven Systems
Event-Driven mORMot
• REST/JSON Persistence via ORM/ODM
– Advanced ORM features
• REST Convention-Over-Configuration routing
• Direct DB-to-JSON serialization (no TDataSet)
• Built-in statement and JSON cache
• Batch (Unit-Of-Work) writes: bulk SQL/NoSQL insert
• SQL logging/timing, real-time replication,
data sharding, remote proxying
Microservices – Event Driven Systems
Event-Driven mORMot
• Cross-platform
– Main mORMot units
• Delphi: Windows x86/x64
Best IDE experience for coding and debugging
• FPC: Windows, MacOS, Android, Linux, BSD
x86/x64, ARM32/AARCH64 (PPC32/PPC64)
• (Cross)Kylix: Linux x86
Microservices – Event Driven Systems
Event-Driven mORMot
• Cross-platform
– Generated client code using Mustache templates
• Delphi: Windows, MacOS, Android, iOS
• FPC: Windows, MacOS, Android, iOS, Linux, …
• (Cross)Kylix: Linux
• SmartMobileStudio: JavaScript Ajax / HTML5
– Featuring almost all framework abilities
• JSON marshalling, security, instance lifetime
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Specify the callback as an interface parameter
• Native way of coding in object pascal
– Real-time push notifications over WebSockets
• Upgraded from a standard HTTP connection
– Peer To Peer communication
• No need of a centralized message bus / server
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Real-time push notifications over WebSockets
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Specify the callback as an interface parameter
ILongWorkCallback = interface(IInvokable)
...
end;
ILongWorkService = interface(IInvokable)
['{09FDFCEF-86E5-4077-80D8-661801A9224A}']
procedure StartWork(const workName: string;
const onFinish: ILongWorkCallback);
function TotalWorkCount: Integer;
end;
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Real-time push notifications over WebSockets
• Once upgraded, communicates using frames
over a bi-directional socket connection
using application-level protocols
• Security, frames gathering, REST emulation
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Real-time push notifications over WebSockets
• Once upgraded, communicates using frames
over a bi-directional socket connection
using application-level protocols
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Security, Frames gathering, REST emulation
• TWebSocketProtocolBinary = SynLZ + AES-256
• Regular blocking methods expecting results
will be emulated like regular REST requests,
with REST security and parameters marshalling
• Non-blocking methods with no result
will be asynchronously sent,
optionally gathered as “jumbo frames”
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Publish/Subscribe Pattern
also known as “Observer”
Publisher
Subscriber 1
Event
Subscriber 2
Event
Subscriber 3
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Beware of “Race Conditions”
• Use critical sections (e.g. TSynLocker)
to protect your shared data on multi-threaded server
• You can gather all non-blocking callback process in a
background thread via TSQLRest.AsynchRedirect
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Beware of “Dead Locks”
• If your callback triggers another method
which shares the same critical section
in another thread, you may block both threads
• You can gather all non-blocking callback process in a
background thread via TSQLRest.AsynchRedirect
Microservices – Event Driven Systems
Event-Driven mORMot
• Interface-based services callbacks
– Sample 31
• Long-Work Push Notification
also known as “Sagas”
• Publish/Subscribe Pattern
also known as “Observer”
Microservices – Event Driven Systems
• Credits
Martin Fowler
https://martinfowler.com
code and samples at
https://synopse.info
Microservices – Event Driven Systems
Event-Driven Systems
• Questions?

More Related Content

What's hot

Directions for CloudStack Networking
Directions for CloudStack  NetworkingDirections for CloudStack  Networking
Directions for CloudStack NetworkingChiradeep Vittal
 
WebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceWebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceRick Hightower
 
GWT Enterprise Edition
GWT Enterprise EditionGWT Enterprise Edition
GWT Enterprise EditionGilad Garon
 
A tour of Java and the JVM
A tour of Java and the JVMA tour of Java and the JVM
A tour of Java and the JVMAlex Birch
 
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013Christopher Curtin
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Lucas Jellema
 
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...Gilad Garon
 
Microservices with Node.js and Apache Cassandra
Microservices with Node.js and Apache CassandraMicroservices with Node.js and Apache Cassandra
Microservices with Node.js and Apache CassandraJorge Bay Gondra
 
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker ContainersKafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containersconfluent
 
Quantum (OpenStack Meetup Feb 9th, 2012)
Quantum (OpenStack Meetup Feb 9th, 2012)Quantum (OpenStack Meetup Feb 9th, 2012)
Quantum (OpenStack Meetup Feb 9th, 2012)Dan Wendlandt
 
Comparing CoAP vs MQTT
Comparing CoAP vs MQTTComparing CoAP vs MQTT
Comparing CoAP vs MQTTkellogh
 
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...Dennis Doomen
 
Network Functions Virtualization and CloudStack
Network Functions Virtualization and CloudStackNetwork Functions Virtualization and CloudStack
Network Functions Virtualization and CloudStackChiradeep Vittal
 
OpenDaylight and YANG
OpenDaylight and YANGOpenDaylight and YANG
OpenDaylight and YANGCoreStack
 
JavaEdge 2008: Your next version control system
JavaEdge 2008: Your next version control systemJavaEdge 2008: Your next version control system
JavaEdge 2008: Your next version control systemGilad Garon
 
Deep Dive: OpenStack Summit (Red Hat Summit 2014)
Deep Dive: OpenStack Summit (Red Hat Summit 2014)Deep Dive: OpenStack Summit (Red Hat Summit 2014)
Deep Dive: OpenStack Summit (Red Hat Summit 2014)Stephen Gordon
 

What's hot (19)

Directions for CloudStack Networking
Directions for CloudStack  NetworkingDirections for CloudStack  Networking
Directions for CloudStack Networking
 
WebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST MicroserviceWebSocket MicroService vs. REST Microservice
WebSocket MicroService vs. REST Microservice
 
GWT Enterprise Edition
GWT Enterprise EditionGWT Enterprise Edition
GWT Enterprise Edition
 
Microservices deck
Microservices deckMicroservices deck
Microservices deck
 
A tour of Java and the JVM
A tour of Java and the JVMA tour of Java and the JVM
A tour of Java and the JVM
 
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
 
Java one2013
Java one2013Java one2013
Java one2013
 
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
Continuous Deployment into the Unknown with Artifactory, Bintray, Docker and ...
 
Microservices with Node.js and Apache Cassandra
Microservices with Node.js and Apache CassandraMicroservices with Node.js and Apache Cassandra
Microservices with Node.js and Apache Cassandra
 
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker ContainersKafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
 
Quantum (OpenStack Meetup Feb 9th, 2012)
Quantum (OpenStack Meetup Feb 9th, 2012)Quantum (OpenStack Meetup Feb 9th, 2012)
Quantum (OpenStack Meetup Feb 9th, 2012)
 
Comparing CoAP vs MQTT
Comparing CoAP vs MQTTComparing CoAP vs MQTT
Comparing CoAP vs MQTT
 
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
Decomposing the monolith into embeddable microservices using OWIN, WebHooks, ...
 
Network Functions Virtualization and CloudStack
Network Functions Virtualization and CloudStackNetwork Functions Virtualization and CloudStack
Network Functions Virtualization and CloudStack
 
OpenDaylight and YANG
OpenDaylight and YANGOpenDaylight and YANG
OpenDaylight and YANG
 
JavaEdge 2008: Your next version control system
JavaEdge 2008: Your next version control systemJavaEdge 2008: Your next version control system
JavaEdge 2008: Your next version control system
 
Fabric8 mq
Fabric8 mqFabric8 mq
Fabric8 mq
 
Deep Dive: OpenStack Summit (Red Hat Summit 2014)
Deep Dive: OpenStack Summit (Red Hat Summit 2014)Deep Dive: OpenStack Summit (Red Hat Summit 2014)
Deep Dive: OpenStack Summit (Red Hat Summit 2014)
 

Similar to Ekon21 Microservices - Event Driven Design

CQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsCQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsMichael Blackstock
 
[DSC Europe 23] Pramod Immaneni - Real-time analytics at IoT scale
[DSC Europe 23] Pramod Immaneni - Real-time analytics at IoT scale[DSC Europe 23] Pramod Immaneni - Real-time analytics at IoT scale
[DSC Europe 23] Pramod Immaneni - Real-time analytics at IoT scaleDataScienceConferenc1
 
Manage the Data Center Network as We Do the Servers
Manage the Data Center Network as We Do the ServersManage the Data Center Network as We Do the Servers
Manage the Data Center Network as We Do the ServersOpen Networking Summits
 
Event Driven Architectures - Phoenix Java Users Group 2013
Event Driven Architectures - Phoenix Java Users Group 2013Event Driven Architectures - Phoenix Java Users Group 2013
Event Driven Architectures - Phoenix Java Users Group 2013clairvoyantllc
 
Event Driven Architectures
Event Driven ArchitecturesEvent Driven Architectures
Event Driven ArchitecturesAvinash Ramineni
 
Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...
Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...
Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...Tony Erwin
 
Instrumenting the real-time web: Node.js in production
Instrumenting the real-time web: Node.js in productionInstrumenting the real-time web: Node.js in production
Instrumenting the real-time web: Node.js in productionbcantrill
 
Kaseya Connect 2012 - THE ABC'S OF MONITORING
Kaseya Connect 2012 - THE ABC'S OF MONITORINGKaseya Connect 2012 - THE ABC'S OF MONITORING
Kaseya Connect 2012 - THE ABC'S OF MONITORINGKaseya
 
DockerCon SF 2015 : Reliably shipping containers in a resource rich world usi...
DockerCon SF 2015 : Reliably shipping containers in a resource rich world usi...DockerCon SF 2015 : Reliably shipping containers in a resource rich world usi...
DockerCon SF 2015 : Reliably shipping containers in a resource rich world usi...Docker, Inc.
 
CCNA-Open-Platform-IoT
CCNA-Open-Platform-IoTCCNA-Open-Platform-IoT
CCNA-Open-Platform-IoTMichael Koster
 
Open Horizontal Platform - Web Scale Interoperability for the Internet of Thi...
Open Horizontal Platform - Web Scale Interoperability for the Internet of Thi...Open Horizontal Platform - Web Scale Interoperability for the Internet of Thi...
Open Horizontal Platform - Web Scale Interoperability for the Internet of Thi...Michael Koster
 
Open Horizontal Platform - Web Scale Interoperability for IoT - CCNA 2013
Open Horizontal Platform - Web Scale Interoperability for IoT - CCNA 2013Open Horizontal Platform - Web Scale Interoperability for IoT - CCNA 2013
Open Horizontal Platform - Web Scale Interoperability for IoT - CCNA 2013Michael Koster
 
OpenWhisk: Where Did My Servers Go?
OpenWhisk: Where Did My Servers Go?OpenWhisk: Where Did My Servers Go?
OpenWhisk: Where Did My Servers Go?Carlos Santana
 
Case-study about build MES Integration System
Case-study about build MES Integration SystemCase-study about build MES Integration System
Case-study about build MES Integration SystemPrzemyslaw Wojtunik
 
Iot cloud service v2.0
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0Vinod Wilson
 
PLNOG 13: Michał Dubiel: OpenContrail software architecture
PLNOG 13: Michał Dubiel: OpenContrail software architecturePLNOG 13: Michał Dubiel: OpenContrail software architecture
PLNOG 13: Michał Dubiel: OpenContrail software architecturePROIDEA
 
Day 5 - Real-time Data Processing/Internet of Things (IoT) with Amazon Kinesis
Day 5 - Real-time Data Processing/Internet of Things (IoT) with Amazon KinesisDay 5 - Real-time Data Processing/Internet of Things (IoT) with Amazon Kinesis
Day 5 - Real-time Data Processing/Internet of Things (IoT) with Amazon KinesisAmazon Web Services
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Adam Dunkels
 

Similar to Ekon21 Microservices - Event Driven Design (20)

CQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applicationsCQRS and Event Sourcing for IoT applications
CQRS and Event Sourcing for IoT applications
 
Sensu Monitoring
Sensu MonitoringSensu Monitoring
Sensu Monitoring
 
Windows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
 
[DSC Europe 23] Pramod Immaneni - Real-time analytics at IoT scale
[DSC Europe 23] Pramod Immaneni - Real-time analytics at IoT scale[DSC Europe 23] Pramod Immaneni - Real-time analytics at IoT scale
[DSC Europe 23] Pramod Immaneni - Real-time analytics at IoT scale
 
Manage the Data Center Network as We Do the Servers
Manage the Data Center Network as We Do the ServersManage the Data Center Network as We Do the Servers
Manage the Data Center Network as We Do the Servers
 
Event Driven Architectures - Phoenix Java Users Group 2013
Event Driven Architectures - Phoenix Java Users Group 2013Event Driven Architectures - Phoenix Java Users Group 2013
Event Driven Architectures - Phoenix Java Users Group 2013
 
Event Driven Architectures
Event Driven ArchitecturesEvent Driven Architectures
Event Driven Architectures
 
Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...
Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...
Monitoring Node.js Microservices on CloudFoundry with Open Source Tools and a...
 
Instrumenting the real-time web: Node.js in production
Instrumenting the real-time web: Node.js in productionInstrumenting the real-time web: Node.js in production
Instrumenting the real-time web: Node.js in production
 
Kaseya Connect 2012 - THE ABC'S OF MONITORING
Kaseya Connect 2012 - THE ABC'S OF MONITORINGKaseya Connect 2012 - THE ABC'S OF MONITORING
Kaseya Connect 2012 - THE ABC'S OF MONITORING
 
DockerCon SF 2015 : Reliably shipping containers in a resource rich world usi...
DockerCon SF 2015 : Reliably shipping containers in a resource rich world usi...DockerCon SF 2015 : Reliably shipping containers in a resource rich world usi...
DockerCon SF 2015 : Reliably shipping containers in a resource rich world usi...
 
CCNA-Open-Platform-IoT
CCNA-Open-Platform-IoTCCNA-Open-Platform-IoT
CCNA-Open-Platform-IoT
 
Open Horizontal Platform - Web Scale Interoperability for the Internet of Thi...
Open Horizontal Platform - Web Scale Interoperability for the Internet of Thi...Open Horizontal Platform - Web Scale Interoperability for the Internet of Thi...
Open Horizontal Platform - Web Scale Interoperability for the Internet of Thi...
 
Open Horizontal Platform - Web Scale Interoperability for IoT - CCNA 2013
Open Horizontal Platform - Web Scale Interoperability for IoT - CCNA 2013Open Horizontal Platform - Web Scale Interoperability for IoT - CCNA 2013
Open Horizontal Platform - Web Scale Interoperability for IoT - CCNA 2013
 
OpenWhisk: Where Did My Servers Go?
OpenWhisk: Where Did My Servers Go?OpenWhisk: Where Did My Servers Go?
OpenWhisk: Where Did My Servers Go?
 
Case-study about build MES Integration System
Case-study about build MES Integration SystemCase-study about build MES Integration System
Case-study about build MES Integration System
 
Iot cloud service v2.0
Iot cloud service v2.0Iot cloud service v2.0
Iot cloud service v2.0
 
PLNOG 13: Michał Dubiel: OpenContrail software architecture
PLNOG 13: Michał Dubiel: OpenContrail software architecturePLNOG 13: Michał Dubiel: OpenContrail software architecture
PLNOG 13: Michał Dubiel: OpenContrail software architecture
 
Day 5 - Real-time Data Processing/Internet of Things (IoT) with Amazon Kinesis
Day 5 - Real-time Data Processing/Internet of Things (IoT) with Amazon KinesisDay 5 - Real-time Data Processing/Internet of Things (IoT) with Amazon Kinesis
Day 5 - Real-time Data Processing/Internet of Things (IoT) with Amazon Kinesis
 
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
Building the Internet of Things with Thingsquare and Contiki - day 1, part 3
 

More from Arnaud Bouchez

EKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfEKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfArnaud Bouchez
 
EKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfEKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfArnaud Bouchez
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsArnaud Bouchez
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyArnaud Bouchez
 
Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Arnaud Bouchez
 
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotEkon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotArnaud Bouchez
 
Ekon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignEkon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignArnaud Bouchez
 
Ekon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiEkon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiArnaud Bouchez
 
Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Arnaud Bouchez
 
D1 from interfaces to solid
D1 from interfaces to solidD1 from interfaces to solid
D1 from interfaces to solidArnaud Bouchez
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-designArnaud Bouchez
 
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotDelphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotArnaud Bouchez
 

More from Arnaud Bouchez (18)

EKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdfEKON27-FrameworksTuning.pdf
EKON27-FrameworksTuning.pdf
 
EKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdfEKON27-FrameworksExpressiveness.pdf
EKON27-FrameworksExpressiveness.pdf
 
Ekon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side NotificationsEkon25 mORMot 2 Server-Side Notifications
Ekon25 mORMot 2 Server-Side Notifications
 
Ekon25 mORMot 2 Cryptography
Ekon25 mORMot 2 CryptographyEkon25 mORMot 2 Cryptography
Ekon25 mORMot 2 Cryptography
 
Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2Ekon24 from Delphi to AVX2
Ekon24 from Delphi to AVX2
 
Ekon24 mORMot 2
Ekon24 mORMot 2Ekon24 mORMot 2
Ekon24 mORMot 2
 
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMotEkon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
Ekon23 (2) Kingdom-Driven-Design applied to Social Media with mORMot
 
Ekon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-DesignEkon23 (1) Kingdom-Driven-Design
Ekon23 (1) Kingdom-Driven-Design
 
Ekon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop DelphiEkon20 mORMot WorkShop Delphi
Ekon20 mORMot WorkShop Delphi
 
Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference Ekon20 mORMot SOA Delphi Conference
Ekon20 mORMot SOA Delphi Conference
 
2016 mORMot
2016 mORMot2016 mORMot
2016 mORMot
 
A1 from n tier to soa
A1 from n tier to soaA1 from n tier to soa
A1 from n tier to soa
 
D1 from interfaces to solid
D1 from interfaces to solidD1 from interfaces to solid
D1 from interfaces to solid
 
A3 from sql to orm
A3 from sql to ormA3 from sql to orm
A3 from sql to orm
 
A2 from soap to rest
A2 from soap to restA2 from soap to rest
A2 from soap to rest
 
D2 domain driven-design
D2 domain driven-designD2 domain driven-design
D2 domain driven-design
 
A4 from rad to mvc
A4 from rad to mvcA4 from rad to mvc
A4 from rad to mvc
 
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMotDelphi ORM SOA MVC SQL NoSQL JSON REST mORMot
Delphi ORM SOA MVC SQL NoSQL JSON REST mORMot
 

Recently uploaded

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROmotivationalword821
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 

Recently uploaded (20)

Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
How To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTROHow To Manage Restaurant Staff -BTRESTRO
How To Manage Restaurant Staff -BTRESTRO
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 

Ekon21 Microservices - Event Driven Design

  • 1. Microservices – Event Driven Systems Arnaud Bouchez - Synopse MICROSERVICES Event Driven Design
  • 2. Microservices – Event Driven Systems • Arnaud Bouchez – Delphi Expert • Various solutions (from Vatican to gaming industry) • IoT solution (RSI) • Real-time Monitoring solution (LiveMon) – Open Source • mORMot (SOA ORM MVC framework) • SynPDF SynMustache SynDB SynCrypto – Training and consultancy • Synopse one-man company
  • 3. Microservices – Event Driven Systems Event-Driven Systems • Using Events? • Event-Driven Design • Event-Driven mORMot
  • 4. Microservices – Event Driven Systems Using Events? • Imperative Architecture – Events are high-level commands
  • 5. Microservices – Event Driven Systems Using Events? • Imperative Architecture – Events are high-level commands • Easy modelization into regular code procedure TZen.HandleIAmGoingOut(Sender: TPeople); var temp: TTemperature; begin temp := TemperatureSensor.GetTemperature; if temp > Threshold then RoboValet.FetchDownJacket(Sender); end;
  • 6. Microservices – Event Driven Systems Using Events? • Imperative Architecture – State is stored in a main shared DB – Events are high-level commands translated into SQL statements
  • 7. Microservices – Event Driven Systems Using Events? • Imperative Architecture – State is stored in a main shared DB – Events are high-level commands translated into SQL statements • DB-centric approach • Atomicity is ensured, but history is lost • DB becomes a bottleneck
  • 8. Microservices – Event Driven Systems Using Events? • Event-Driven Architecture – Collaboration is done using Events
  • 9. Microservices – Event Driven Systems Using Events? • Event-Driven Architecture – Collaboration is done using Events Just like VCL/FMX /LCL !
  • 10. Microservices – Event Driven Systems Using Events? • Event-Driven Architecture – Collaboration is done using Events – System consists in uncoupled nodes which could be added or removed on-the-fly – Nodes publish events, and subscribe to them – Each node stores the information it needs – Some API gateways expose state via REST
  • 11. Microservices – Event Driven Systems Event-Driven Architecture • Nodes implemented as services procedure TZen.Init; begin TemperatureSensor.SubscribeToTempChange(OnTempChanged); end; procedure TZen.OnTempChanged(NewTemp: TTemperature); begin CurrentTemp := NewTemp; end; procedure TZen.HandleIAmGoingOut(Sender: TPeople); begin if CurrentTemp > Threshold then RoboValet.NotifyNeedsJacket(Sender); end;
  • 12. Microservices – Event Driven Systems Event-Driven Architecture – Collaboration is done using Events Not natural to imperative code (Delphi, C#, Java) – System consists in uncoupled nodes Architecture becomes complex – Nodes publish events, and subscribe to them May be subject to unexpected loops – Each node stores the information it needs Duplicated data, with eventual consistency
  • 13. Microservices – Event Driven Systems Event-Driven Architecture • More complex than imperative code procedure TZen.HandleIAmGoingOut(Sender: TPeople); var temp: TTemperature; begin temp := TemperatureSensor.GetTemperature; if temp > Threshold then RoboValet.FetchDownJacket(Sender); end;
  • 14. Microservices – Event Driven Systems Event-Driven Architecture • Events may be received for no use e.g. the following method is always called procedure TZen.OnTempChanged(NewTemp: TTemperature); begin CurrentTemp := NewTemp; end; but this value may never be used in procedure TZen.HandleIAmGoingOut(Sender: TPeople); begin if CurrentTemp > Threshold then RoboValet.NotifyNeedsJacket(Sender); end;
  • 15. Microservices – Event Driven Systems Event-Driven Architecture • Danger of unexpected infinite loop procedure TZen.HandleIAmGoingOut(Sender: TPeople); begin if CurrentTemp > Threshold then RoboValet.NotifyNeedsJacket(Sender); end; What happens if RoboValet.NotifyNeedsJacket triggers (indirectly) TZen.HandleIAmGoingOut ? Since nodes may be added at any time, how to prevent it to happen?
  • 16. Microservices – Event Driven Systems Event-Driven Architecture • Danger of unexpected infinite loop procedure TZen.HandleIAmGoingOut(Sender: TPeople); begin if CurrentTemp > Threshold then RoboValet.NotifyNeedsJacket(Sender); end; What happens if RoboValet.NotifyNeedsJacket triggers (indirectly) TZen.HandleIAmGoingOut ? Enter the Event-Driven debugging hell: actual event process depends on the system it runs on
  • 17. Microservices – Event Driven Systems Event-Driven Architecture • So, when to use it? – Your are modeling evolving information • e.g. scale to a lot of devices or users – You need to track changes of state • A monolithic DB only stores the current state (via Update) - otherwise it may sink under Inserts • Event-Sourcing and CQRS (see later)
  • 18. Microservices – Event Driven Systems Event-Driven Architecture • So, when to use it? – You expect a modular design • Process not written in stone during compilation (as in imperative programming): add/enable nodes to change the system behavior at runtime • Microservices, SaaS, horizontal scaling
  • 19. Microservices – Event Driven Systems Event-Driven Architecture • So, when to use it? – You defined a stateless domain • From state comes complexity, so DDD usually modelizes a time snapshot • DDD events are a way to introduce temporality – Never 100% Event-Driven • You will eventually define REST API gateways
  • 20. Microservices – Event Driven Systems Event-Driven Architecture • Message Bus – Most common way to implement Event-Driven • Cloud, Local or in-house Queues • Like VCL TApplication.ProcessMessages – Publish/Subscribe mechanism • Nodes get only needed information • Nodes could be added/removed – Used in conjunction with regular DB and REST
  • 21. Microservices – Event Driven Systems Event-Driven Architecture • Message Bus
  • 22. Microservices – Event Driven Systems Event-Driven Architecture • Peer to peer communication – Nodes communicate directly between them • Each node manages its own queue(s) • Good integration with REST • Need a centralized catalog service, P2P ZeroMQ, or convention-over-configuration setup • As offered by mORMot over WebSockets
  • 23. Microservices – Event Driven Systems Event-Driven Architecture • Event Sourcing – Business logic is implemented through Events – Events are persisted, not state • Play the events to compute a state • Intermediate states may be cached/persisted – Events are transmitted, not state • Publish/Subscribe instead of REST • Define API gateways for the outer world
  • 24. Microservices – Event Driven Systems Event-Driven Architecture • Event Sourcing – Business logic is implemented through Events – Convenient way to define Microservices • Subscribe to events, to get the information • Publish events, as result of the process – Microservices persistence • Most Microservices will use a regular state storage • Some Microservices will use Event Sourcing
  • 25. Microservices – Event Driven Systems Event-Driven Architecture • Events and CQRS – Command Query Responsibility Segregation • Commands triggers events • Events are gathered and stored • State/Events store is uncoupled from Commands – CQRS follows a non CRUD pattern • Create Read Update Delete
  • 26. Microservices – Event Driven Systems Event-Driven Architecture • CRUD DB
  • 27. Microservices – Event Driven Systems Event-Driven Architecture • CQRS DB
  • 28. Microservices – Event Driven Systems Event-Driven mORMot
  • 29. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services type ICalculator = interface(IInvokable) ['{9A60C8ED-CEB2-4E09-87D4-4A16F496E5FE}'] /// add two signed 32 bit integers function Add(n1,n2: integer): integer; end; – Defines the contract of the service – Microservice: should follow SOLID principles
  • 30. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services procedure ResolveCalculator(out: ICalculator); ... function TMyClient.MyAdd(a,b: integer): integer; var Calculator: ICalculator; begin Client.Services.Resolve(ICalculator, Calculator); result := Calculator.Add(a,b); end; – Runtime injection of the actual implementation • May be in-process, local or remote
  • 31. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services var Calculator: ICalculator; begin Client.Services.Resolve(ICalculator, Calculator); result := Calculator.Add(a,b); end; – Client is a mORMot TSQLRestClientURI – Will communicate using JSON over HTTP(S)
  • 32. Microservices – Event Driven Systems Event-Driven mORMot • RESTful Local and Client-Server – In-process Stand-alone client, fast server-side access – Named pipes or Windows messages Stand-alone client, fast server-side access – HTTP/1.1 via kernel-mode http.sys API • Kernel-mode execution, IOCP driven, https – Windows specific – HTTP/1.1 via OS socket API • Windows or Linux, using a Thread Pool, https via Reverse Proxy • Upgradable to WebSockets
  • 33. Microservices – Event Driven Systems Event-Driven mORMot • RESTful Client TSQLRestServer TSQLRest TSQLRestClientURI TSQLRestClient
  • 34. Microservices – Event Driven Systems Event-Driven mORMot • RESTful Server TSQLRestServerDB TSQLRestServer TSQLRest TSQLRestServerRemoteDB TSQLRestServerFullMemory
  • 35. Microservices – Event Driven Systems Event-Driven mORMot • RESTful Local and Client-Server – Needed methods are available at TSQLRest • REST auto-routing • JSON high-performance serialization • Following Liskov Substitution Principle – Focus on the logic – Abstract from the plumbing
  • 36. Microservices – Event Driven Systems Event-Driven mORMot • REST/JSON Persistence via ORM/ODM – Agnostic Storage for Events or State • ORM over local SQlite3 store • ORM over remote SQL databases • ODM over TObjectList • ODM over MongoDB Switching from one to another in a few lines of code, or through settings
  • 37. Microservices – Event Driven Systems Event-Driven mORMot • REST/JSON Persistence via ORM/ODM – Advanced ORM features • REST Convention-Over-Configuration routing • Direct DB-to-JSON serialization (no TDataSet) • Built-in statement and JSON cache • Batch (Unit-Of-Work) writes: bulk SQL/NoSQL insert • SQL logging/timing, real-time replication, data sharding, remote proxying
  • 38. Microservices – Event Driven Systems Event-Driven mORMot • Cross-platform – Main mORMot units • Delphi: Windows x86/x64 Best IDE experience for coding and debugging • FPC: Windows, MacOS, Android, Linux, BSD x86/x64, ARM32/AARCH64 (PPC32/PPC64) • (Cross)Kylix: Linux x86
  • 39. Microservices – Event Driven Systems Event-Driven mORMot • Cross-platform – Generated client code using Mustache templates • Delphi: Windows, MacOS, Android, iOS • FPC: Windows, MacOS, Android, iOS, Linux, … • (Cross)Kylix: Linux • SmartMobileStudio: JavaScript Ajax / HTML5 – Featuring almost all framework abilities • JSON marshalling, security, instance lifetime
  • 40. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Specify the callback as an interface parameter • Native way of coding in object pascal – Real-time push notifications over WebSockets • Upgraded from a standard HTTP connection – Peer To Peer communication • No need of a centralized message bus / server
  • 41. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Real-time push notifications over WebSockets
  • 42. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Specify the callback as an interface parameter ILongWorkCallback = interface(IInvokable) ... end; ILongWorkService = interface(IInvokable) ['{09FDFCEF-86E5-4077-80D8-661801A9224A}'] procedure StartWork(const workName: string; const onFinish: ILongWorkCallback); function TotalWorkCount: Integer; end;
  • 43. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Real-time push notifications over WebSockets • Once upgraded, communicates using frames over a bi-directional socket connection using application-level protocols • Security, frames gathering, REST emulation
  • 44. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Real-time push notifications over WebSockets • Once upgraded, communicates using frames over a bi-directional socket connection using application-level protocols
  • 45. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Security, Frames gathering, REST emulation • TWebSocketProtocolBinary = SynLZ + AES-256 • Regular blocking methods expecting results will be emulated like regular REST requests, with REST security and parameters marshalling • Non-blocking methods with no result will be asynchronously sent, optionally gathered as “jumbo frames”
  • 46. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Publish/Subscribe Pattern also known as “Observer” Publisher Subscriber 1 Event Subscriber 2 Event Subscriber 3
  • 47. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Beware of “Race Conditions” • Use critical sections (e.g. TSynLocker) to protect your shared data on multi-threaded server • You can gather all non-blocking callback process in a background thread via TSQLRest.AsynchRedirect
  • 48. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Beware of “Dead Locks” • If your callback triggers another method which shares the same critical section in another thread, you may block both threads • You can gather all non-blocking callback process in a background thread via TSQLRest.AsynchRedirect
  • 49. Microservices – Event Driven Systems Event-Driven mORMot • Interface-based services callbacks – Sample 31 • Long-Work Push Notification also known as “Sagas” • Publish/Subscribe Pattern also known as “Observer”
  • 50. Microservices – Event Driven Systems • Credits Martin Fowler https://martinfowler.com code and samples at https://synopse.info
  • 51. Microservices – Event Driven Systems Event-Driven Systems • Questions?