SlideShare a Scribd company logo
1 of 43
Download to read offline
TYPO3 Event Sourcing Oliver Hader 11/2016
Event Sourcing
… some new opportunities
November 5th, 2016
TYPO3 Event Sourcing Oliver Hader 11/2016
~basics
~bank account example

~generic modelling
~opportunities
TYPO3 Event Sourcing Oliver Hader 11/2016
DDD ~basics
TYPO3 Event Sourcing Oliver Hader 11/2016
Domain-driven Design
• book by Eric Evans, 2003
• robust & maintainable software applications
• domain experts & ubiquitous language
• toolbox for domain architectures
Layered Architecture
User Interface Layer
Application Layer
Domain Layer
Infrastructure Layer
Orchestrates application
and domain layer
Encapsulates domain
and data access
Encapsulates
infrastructure concerns
Aggregates
Customer
Address
Invoice
Car
Wheel
Engine
Garage
CarRental
Survey
car aggregate
customer aggregate
aggregate root
aggregate root
concerns
repairs
interviews
car rental aggregate
Bounded Contexts
Customer
Car
Fuel
CarRental
car rental bounded context
Car
Wheel
Engine
Garage
garage bounded context
Mechanic
Damage
~DomainModelCarRental ~DomainModelGarage
TYPO3 Event Sourcing Oliver Hader 11/2016
Entities & Value Objects
• make the implicit explicit
• make validation part of your domain model
• example for bank account number
• $account-­‐>setIban('CH1504842000000000002');	
  
• $iban	
  =	
  new	
  Iban('CH1504842000000000002');

$account-­‐>setIban($iban);
TYPO3 Event Sourcing Oliver Hader 11/2016
Events
• are messages
• are modelled in separate classes
• concerning something that really happened
• used to communicate between components
• handle with observer patterns (signal-slot)
• $event	
  =	
  new	
  ReplacedBrokenEngineEvent(…);
TYPO3 Event Sourcing Oliver Hader 11/2016
CQRS ~basics
TYPO3 Event Sourcing Oliver Hader 11/2016
CQS
• CQS - Command Query Separation
• actually defined by Bertrand Mayer in 1997
• separate processing in domain model into
• write model - modify state with command
• read model - fetch & represent state with query
TYPO3 Event Sourcing Oliver Hader 11/2016
CQRS
• CQRS - Command Query Responsibility Segregation
• more specific & restrictive by Greg Young
• segregation between write store & read store
• changes trigger updates in read store
• visualization just uses data-transfer objects
CQRS Overview
TYPO3 Event Sourcing Oliver Hader 11/2016
Event Sourcing ~basics
TYPO3 Event Sourcing Oliver Hader 11/2016
Event Sourcing
• … CQRS continued & in more details
• aim to persist events instead of resulting state
• event stores provide read/write capabilities
• applying all events results to current state again
• events are projected into desired formats
TYPO3 Event Sourcing Oliver Hader 11/2016
Events & Event Store
• events are immutable
• cannot be modified
• cannot be deleted
• legacy events must be handled
• event store is consistent
• events are retrieved in correct order
• there are no gaps in the event history
TYPO3 Event Sourcing Oliver Hader 11/2016
Projections
• are observers & handle events
• interpret and persist events to
• MySQL database
• filesystem, e.g. HTML
• emit notifications, mails
• whatever required format
TYPO3 Event Sourcing Oliver Hader 11/2016
Materialized View
• persist information for accordant requirements
• forget about complex JOIN statements
• data is represented denormalized
• pre-process information for view
• read 40 field values vs. just two are shown
Event Sourcing Overview
Command Handler
Command Bus
Repository
ServiceEventPublisher
EventHandler
Denormalizer
Thin Data Layer
Facade
Domain
DTOs
Commands
Aggregate
Events
Events
Events Events
SQL
ClientCommands Queries
External
Events
Internal
Events
some query
results
TYPO3 Event Sourcing Oliver Hader 11/2016
Why??? ~basics
TYPO3 Data Architecture
Repository &
Reconstitution
Routing
Controller
View
Model
Permission
Persistence
Infrastructure
Frontend Extbase Backend
EditDocumentController
FormEngine
<<TCA>>
FormDataProvider
BackendUserAuthentication
DataHandler
RelationHandler
TypoScriptFrontendController
ActionContoller
AbstractView
AbstractEntity & AbstractValueObject
Repository
Typo3DbBackend
Backend
PersistenceManager
DataMapper
StandaloneView <<custom>>
ConnectionPool
Connection
<<TCA>>
AbstractPlugin
ContentObjectRenderer
FrontendRequestHandler
BackendRouteDispatcher
BackendRequestHandler
MVCDispatcher
<<TypoScript>>
<<direct database operations>> <<direct database operations>>
x
x
x
Localization in TYPO3
DataHandlerController
DataHandler
RelationHandler
DatabaseConnection
translate
<<create>>
localize()
copyRecord()
<<create>>
DataHandler
process_datamap()
last_insert_id()
fetch record
record
[x]-processDBdata()
<<create>>
start()
fetch references
references
writeForeignField()
update references
insert record
new_record_id
new_record_id
new_record_id
references
new_record_id
multipleread&writeprocesses
Context & Overlays
is translation of
uid 13
sys_language_uid 0
:tt_content
l10n_parent 0
header Message
pid 100
t3ver_wsid 0
t3ver_state 0
t3ver_oid 0
uid 27
sys_language_uid 1
:tt_content
l10n_parent 13
header Nachricht
pid 100
t3ver_wsid 1
t3ver_state 1
t3ver_oid 0
uid 28
sys_language_uid 1
:tt_content
l10n_parent 13
header Nachricht
pid -1
t3ver_wsid 1
t3ver_state -1
t3ver_oid 27
uid 41
sys_language_uid 0
:tt_content
l10n_parent 0
header News
pid -1
t3ver_wsid 1
t3ver_state 0
t3ver_oid 13
is workspace
version of
is new
version
is default
version
is workspace
version of
is new
palceholder
TYPO3 Event Sourcing Oliver Hader 11/2016
Why…
• is persistence and relation handling different
• extbase cannot persist in workspace context
• only back-end has permission layer
• are context information persisted with each record
• are record overlays fetched & applied each time
TYPO3 Event Sourcing Oliver Hader 11/2016
bank account example
TYPO3 Event Sourcing Oliver Hader 11/2016
Regular approach
• using ExtensionBuilder to kick-start model
• AccountController - modify & read information
• AccountRepository - modify & read information
• Account modelled as aggregate root
• Transaction model bound to Aggregate (1:n)
• using lazy-loading for Transaction entities
TYPO3 Event Sourcing Oliver Hader 11/2016
Identify domain events
• event storming is a team process
• helps to combine knowledge concerning domain
• in style of reverse engineering
• working backwards
• identify events
• identify commands that lead to events
• identify rules that are applied to commands
… during T3DD16
Bank Account Example
debited
money
debit
money
account
not closed
balance
sufficient
account
created
deposit
money
account
not closed
deposited
money
create
account
TYPO3 Event Sourcing Oliver Hader 11/2016
Demo & Source Code
• https://github.com/TYPO3Incubator/
bank_account_example
• Configuration
• CommandController & ManagementController
• Domain Commands & Domain Events
• EventRepositories & ProjectionRepositories
• Projections & Data-Transfer Objects
TYPO3 Event Sourcing Oliver Hader 11/2016
generic modelling
TYPO3 Event Sourcing Oliver Hader 11/2016
Generic Domain Model
• no real models for most core database tables
• generic models contain common aspects
• identity (”tt_content:123”)
• atomic, direct values
• relations to other entities
• ”generic“ is not domain-driven
• but this concept is very useful here
TYPO3 Event Sourcing Oliver Hader 11/2016
Generic Domain Events
• created, modified, deleted ~CRUD (without R)
• moved, duplicated
• hidden, shown ~visibility
• translated ~language context
• branched, merged ~workspace context
• attached, removed, ordered relation ~association
TYPO3 Event Sourcing Oliver Hader 11/2016
Interceptors
• DataHandler ~$tce->process_datamap();
• DatabaseConnection ~INSERT, UPDATE, DELETE
• translate actions into generic commands
• $GLOBALS['TCA'][…]['ctrl']['eventSourcing']=[

	
  	
  	
  	
  'listenEvents'	
  =>	
  true,

	
  	
  	
  	
  'recordEvents'	
  =>	
  true,

	
  	
  	
  	
  'projectEvents'	
  =>	
  true,
TYPO3 Event Sourcing Oliver Hader 11/2016
Command Upgrades
• tranlate generic to specific domain commands
• delegates domain control back to application
• back to bank account example
• does not need to implement generic commands
• action in back-end form result in real commands
TYPO3 Event Sourcing Oliver Hader 11/2016
Context & Local Storage
• Materialized View on database-level
• workspace and language define specific context
• each context uses an individual database
• information stored in SQLite locally
• projections update for each context
• it was named Local Storage
Local Storage
DEFAULT
MySQL
- _conn: DriverConnection
Connection
+ select(...arguments[])
+ insert(…arguments[])
+ update(…arguments[])
+ delete(…arguments[])
ORIGIN
MySQL
- _conn: DriverConnection
Connection
+ select(...arguments[])
+ insert(…arguments[])
+ update(…arguments[])
+ delete(…arguments[])
DefaultConnection
LocalStorage
workspace-0
SQLite
- _conn: DriverConnection
Connection
+ select(...arguments[])
+ insert(…arguments[])
+ update(…arguments[])
+ delete(…arguments[])
DefaultConnection
LocalStorage
workspace-1
SQLite
- _conn: DriverConnection
Connection
+ select(...arguments[])
+ insert(…arguments[])
+ update(…arguments[])
+ delete(…arguments[])
current state future state, context based
assigned
to
assigned to
TYPO3 Event Sourcing Oliver Hader 11/2016
Demo & Source Code
• https://github.com/TYPO3Incubator/data_handling
• Content Editing in back-end
• Event Store results
• Projections
• Command Translations
TYPO3 Event Sourcing Oliver Hader 11/2016
opportunities
TYPO3 Event Sourcing Oliver Hader 11/2016
Projections!
• separation between mutation & presentation
• events are the new & only true source
• everything else can be projected
• … and re-projected if it was wrong
• e.g. https://review.typo3.org/#/c/45320/
• trigger index update (Solr, Elasticsearc)
TYPO3 Event Sourcing Oliver Hader 11/2016
Questions?
TYPO3 Event Sourcing Oliver Hader 11/2016
Sources
• Figures
• “Layered Architecture“ - Buenosvinos, Carlos, Soronellas, Christian und Akbary, Keyvan. 2016. Domain-
Driven Design in PHP. Victoria : Leanpub, 2016. ISBN 9780994608413
• ”CQRS Overview“ - Betts, Dominic, et al. 2013. Exploring CQRS and Event Sourcing. Redmond : Microsoft
patterns & practices, 2013. ISBN 9781621140160
• ”Event Sourcing Overview“ - Nijhof, Mark. 2013. CQRS, The example. Victoria : Leanpub, 2013. ISBN
9781484102879
• GitHub source codes
• https://github.com/TYPO3Incubator/bank_account_example
• https://github.com/TYPO3Incubator/data_handling
• Master Thesis on Event Sourcing (German only)
• https://get.h4ck3r31.net/T3CRR16-HwWL498EvURCxnnittPoHyNrXkN3xi/
Hader_Oliver_TYPO3_EventSourcing.pdf
TYPO3 Event Sourcing Oliver Hader 11/2016
Thank you!
ohader

@ohader

Oliver_Hader
follow mehttps://h4ck3r31.net

More Related Content

What's hot

[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
CODE BLUE
 

What's hot (20)

Zap vs burp
Zap vs burpZap vs burp
Zap vs burp
 
There’s an OpenBullet Attack Config for Your Site – What Should You Do?
There’s an OpenBullet Attack Config for Your Site – What Should You Do?There’s an OpenBullet Attack Config for Your Site – What Should You Do?
There’s an OpenBullet Attack Config for Your Site – What Should You Do?
 
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
Defeating firefox by Muneaki Nishimunea - CODE BLUE 2015
 
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...
Abusing Adobe Reader’s JavaScript APIs by Abdul-Aziz Hariri & Brian Gorenc - ...
 
SANS @Night Talk: SQL Injection Exploited
SANS @Night Talk: SQL Injection ExploitedSANS @Night Talk: SQL Injection Exploited
SANS @Night Talk: SQL Injection Exploited
 
CMS Hacking Tricks - DerbyCon 4 - 2014
CMS Hacking Tricks - DerbyCon 4 - 2014CMS Hacking Tricks - DerbyCon 4 - 2014
CMS Hacking Tricks - DerbyCon 4 - 2014
 
Eyeing the Onion
Eyeing the OnionEyeing the Onion
Eyeing the Onion
 
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
 
Offensive Python for Pentesting
Offensive Python for PentestingOffensive Python for Pentesting
Offensive Python for Pentesting
 
Cloud security best practices in AWS by: Ankit Giri
Cloud security best practices in AWS by: Ankit GiriCloud security best practices in AWS by: Ankit Giri
Cloud security best practices in AWS by: Ankit Giri
 
Zentral macaduk conf 2016
Zentral macaduk conf 2016Zentral macaduk conf 2016
Zentral macaduk conf 2016
 
BSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad GuysBSIDES-PR Keynote Hunting for Bad Guys
BSIDES-PR Keynote Hunting for Bad Guys
 
Web security for developers
Web security for developersWeb security for developers
Web security for developers
 
Introduction to red team operations
Introduction to red team operationsIntroduction to red team operations
Introduction to red team operations
 
Zentral london mac_ad_uk_2017
Zentral london mac_ad_uk_2017Zentral london mac_ad_uk_2017
Zentral london mac_ad_uk_2017
 
SignaturesAreDead Long Live RESILIENT Signatures
SignaturesAreDead Long Live RESILIENT SignaturesSignaturesAreDead Long Live RESILIENT Signatures
SignaturesAreDead Long Live RESILIENT Signatures
 
Lares from LOW to PWNED
Lares from LOW to PWNEDLares from LOW to PWNED
Lares from LOW to PWNED
 
Pwning the Enterprise With PowerShell
Pwning the Enterprise With PowerShellPwning the Enterprise With PowerShell
Pwning the Enterprise With PowerShell
 
Zentral presentation MacAdmins meetup Univ. Utah
Zentral presentation MacAdmins meetup Univ. Utah Zentral presentation MacAdmins meetup Univ. Utah
Zentral presentation MacAdmins meetup Univ. Utah
 
Red Team vs Blue Team on AWS - RSA 2018
Red Team vs Blue Team on AWS - RSA 2018Red Team vs Blue Team on AWS - RSA 2018
Red Team vs Blue Team on AWS - RSA 2018
 

Similar to TYPO3 Event Sourcing

Processing Complex Workflows in Advertising using Hadoop
Processing Complex Workflows in Advertising using HadoopProcessing Complex Workflows in Advertising using Hadoop
Processing Complex Workflows in Advertising using Hadoop
DataWorks Summit
 

Similar to TYPO3 Event Sourcing (20)

Growing into a proactive Data Platform
Growing into a proactive Data PlatformGrowing into a proactive Data Platform
Growing into a proactive Data Platform
 
Using Event Streams in Serverless Applications
Using Event Streams in Serverless ApplicationsUsing Event Streams in Serverless Applications
Using Event Streams in Serverless Applications
 
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...
 
Hadoop Summit 2014: Processing Complex Workflows in Advertising Using Hadoop
Hadoop Summit 2014: Processing Complex Workflows in Advertising Using HadoopHadoop Summit 2014: Processing Complex Workflows in Advertising Using Hadoop
Hadoop Summit 2014: Processing Complex Workflows in Advertising Using Hadoop
 
Processing Complex Workflows in Advertising using Hadoop
Processing Complex Workflows in Advertising using HadoopProcessing Complex Workflows in Advertising using Hadoop
Processing Complex Workflows in Advertising using Hadoop
 
The Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and ContainersThe Patterns of Distributed Logging and Containers
The Patterns of Distributed Logging and Containers
 
Data Con LA 2018 - Enabling real-time exploration and analytics at scale at H...
Data Con LA 2018 - Enabling real-time exploration and analytics at scale at H...Data Con LA 2018 - Enabling real-time exploration and analytics at scale at H...
Data Con LA 2018 - Enabling real-time exploration and analytics at scale at H...
 
Realtime Analytics on AWS
Realtime Analytics on AWSRealtime Analytics on AWS
Realtime Analytics on AWS
 
data-mesh-101.pptx
data-mesh-101.pptxdata-mesh-101.pptx
data-mesh-101.pptx
 
The Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data ImplementationThe Great Lakes: How to Approach a Big Data Implementation
The Great Lakes: How to Approach a Big Data Implementation
 
Events and microservices
Events and microservicesEvents and microservices
Events and microservices
 
Real-Time Event Processing
Real-Time Event ProcessingReal-Time Event Processing
Real-Time Event Processing
 
Cqrs and event sourcing in azure
Cqrs and event sourcing in azureCqrs and event sourcing in azure
Cqrs and event sourcing in azure
 
Pinot: Enabling Real-time Analytics Applications @ LinkedIn's Scale
Pinot: Enabling Real-time Analytics Applications @ LinkedIn's ScalePinot: Enabling Real-time Analytics Applications @ LinkedIn's Scale
Pinot: Enabling Real-time Analytics Applications @ LinkedIn's Scale
 
[Hands-on] CQRS(Command Query Responsibility Segregation) 와 Event Sourcing 패턴 실습
[Hands-on] CQRS(Command Query Responsibility Segregation) 와 Event Sourcing 패턴 실습[Hands-on] CQRS(Command Query Responsibility Segregation) 와 Event Sourcing 패턴 실습
[Hands-on] CQRS(Command Query Responsibility Segregation) 와 Event Sourcing 패턴 실습
 
CQRS and Event Sourcing
CQRS and Event Sourcing CQRS and Event Sourcing
CQRS and Event Sourcing
 
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent) K...
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent)  K...Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent)  K...
Event Sourcing, Stream Processing and Serverless (Ben Stopford, Confluent) K...
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
 
Apache Flink 101 - the rise of stream processing and beyond
Apache Flink 101 - the rise of stream processing and beyondApache Flink 101 - the rise of stream processing and beyond
Apache Flink 101 - the rise of stream processing and beyond
 
Event Driven Streaming Analytics - Demostration on Architecture of IoT
Event Driven Streaming Analytics - Demostration on Architecture of IoTEvent Driven Streaming Analytics - Demostration on Architecture of IoT
Event Driven Streaming Analytics - Demostration on Architecture of IoT
 

More from Oliver Hader

TYPO3 CMS - Datenmodifikation & Event Sourcing (Masterarbeit)
TYPO3 CMS - Datenmodifikation & Event Sourcing (Masterarbeit)TYPO3 CMS - Datenmodifikation & Event Sourcing (Masterarbeit)
TYPO3 CMS - Datenmodifikation & Event Sourcing (Masterarbeit)
Oliver Hader
 
TYPO3camp Regensburg: TYPO3 6.0
TYPO3camp Regensburg: TYPO3 6.0TYPO3camp Regensburg: TYPO3 6.0
TYPO3camp Regensburg: TYPO3 6.0
Oliver Hader
 
TYPO3 Inline Relational Record Editing (IRRE)
TYPO3 Inline Relational Record Editing (IRRE)TYPO3 Inline Relational Record Editing (IRRE)
TYPO3 Inline Relational Record Editing (IRRE)
Oliver Hader
 

More from Oliver Hader (14)

T3DD23 Content Security Policy - Concept, Strategies & Pitfalls
T3DD23 Content Security Policy - Concept, Strategies & PitfallsT3DD23 Content Security Policy - Concept, Strategies & Pitfalls
T3DD23 Content Security Policy - Concept, Strategies & Pitfalls
 
Web Application Security Workshop (T3DD19)
Web Application Security Workshop (T3DD19)Web Application Security Workshop (T3DD19)
Web Application Security Workshop (T3DD19)
 
Hacking TYPO3 v9 (T3DD19 edition)
Hacking TYPO3 v9 (T3DD19 edition)Hacking TYPO3 v9 (T3DD19 edition)
Hacking TYPO3 v9 (T3DD19 edition)
 
Hacking TYPO3 v9
Hacking TYPO3 v9Hacking TYPO3 v9
Hacking TYPO3 v9
 
TYPO3camp Munich 2018 - Keynote - "Wo woll'n mer denn hin?"
TYPO3camp Munich 2018 - Keynote - "Wo woll'n mer denn hin?"TYPO3camp Munich 2018 - Keynote - "Wo woll'n mer denn hin?"
TYPO3camp Munich 2018 - Keynote - "Wo woll'n mer denn hin?"
 
TYPO3 CMS - Datenmodifikation & Event Sourcing (Masterarbeit)
TYPO3 CMS - Datenmodifikation & Event Sourcing (Masterarbeit)TYPO3 CMS - Datenmodifikation & Event Sourcing (Masterarbeit)
TYPO3 CMS - Datenmodifikation & Event Sourcing (Masterarbeit)
 
Vor- und Nachteile von Web Components mit Polymer gegenüber AngularJS ohne P...
Vor- und Nachteile von Web Components mit Polymer gegenüber AngularJS ohne P...Vor- und Nachteile von Web Components mit Polymer gegenüber AngularJS ohne P...
Vor- und Nachteile von Web Components mit Polymer gegenüber AngularJS ohne P...
 
WebGL - 3D im Browser - Erfahrungsbericht mit BabylonJS
WebGL - 3D im Browser - Erfahrungsbericht mit BabylonJSWebGL - 3D im Browser - Erfahrungsbericht mit BabylonJS
WebGL - 3D im Browser - Erfahrungsbericht mit BabylonJS
 
Web Components
Web ComponentsWeb Components
Web Components
 
Web application security
Web application securityWeb application security
Web application security
 
T3CON13DE - TYPO3 CMS Team
T3CON13DE - TYPO3 CMS TeamT3CON13DE - TYPO3 CMS Team
T3CON13DE - TYPO3 CMS Team
 
TYPO3camp Regensburg: TYPO3 6.0
TYPO3camp Regensburg: TYPO3 6.0TYPO3camp Regensburg: TYPO3 6.0
TYPO3camp Regensburg: TYPO3 6.0
 
TYPO3 Inline Relational Record Editing (IRRE)
TYPO3 Inline Relational Record Editing (IRRE)TYPO3 Inline Relational Record Editing (IRRE)
TYPO3 Inline Relational Record Editing (IRRE)
 
TYPO3 4.6 & TYPO3 4.7
TYPO3 4.6 & TYPO3 4.7TYPO3 4.6 & TYPO3 4.7
TYPO3 4.6 & TYPO3 4.7
 

Recently uploaded

Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
Sérgio Sacani
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
Sérgio Sacani
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
RohitNehra6
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
gindu3009
 
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxSCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
RizalinePalanog2
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Sérgio Sacani
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
Areesha Ahmad
 

Recently uploaded (20)

Isotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on IoIsotopic evidence of long-lived volcanism on Io
Isotopic evidence of long-lived volcanism on Io
 
Disentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOSTDisentangling the origin of chemical differences using GHOST
Disentangling the origin of chemical differences using GHOST
 
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
All-domain Anomaly Resolution Office U.S. Department of Defense (U) Case: “Eg...
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Botany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdfBotany 4th semester file By Sumit Kumar yadav.pdf
Botany 4th semester file By Sumit Kumar yadav.pdf
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
Botany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdfBotany 4th semester series (krishna).pdf
Botany 4th semester series (krishna).pdf
 
Nanoparticles synthesis and characterization​ ​
Nanoparticles synthesis and characterization​  ​Nanoparticles synthesis and characterization​  ​
Nanoparticles synthesis and characterization​ ​
 
Green chemistry and Sustainable development.pptx
Green chemistry  and Sustainable development.pptxGreen chemistry  and Sustainable development.pptx
Green chemistry and Sustainable development.pptx
 
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43bNightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
Nightside clouds and disequilibrium chemistry on the hot Jupiter WASP-43b
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
❤Jammu Kashmir Call Girls 8617697112 Personal Whatsapp Number 💦✅.
 
Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)Recombinant DNA technology (Immunological screening)
Recombinant DNA technology (Immunological screening)
 
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxSCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
 
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 60009654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
9654467111 Call Girls In Raj Nagar Delhi Short 1500 Night 6000
 
Forensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdfForensic Biology & Its biological significance.pdf
Forensic Biology & Its biological significance.pdf
 
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroidsHubble Asteroid Hunter III. Physical properties of newly found asteroids
Hubble Asteroid Hunter III. Physical properties of newly found asteroids
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
 
Biological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdfBiological Classification BioHack (3).pdf
Biological Classification BioHack (3).pdf
 

TYPO3 Event Sourcing

  • 1. TYPO3 Event Sourcing Oliver Hader 11/2016 Event Sourcing … some new opportunities November 5th, 2016
  • 2. TYPO3 Event Sourcing Oliver Hader 11/2016 ~basics ~bank account example
 ~generic modelling ~opportunities
  • 3. TYPO3 Event Sourcing Oliver Hader 11/2016 DDD ~basics
  • 4. TYPO3 Event Sourcing Oliver Hader 11/2016 Domain-driven Design • book by Eric Evans, 2003 • robust & maintainable software applications • domain experts & ubiquitous language • toolbox for domain architectures
  • 5. Layered Architecture User Interface Layer Application Layer Domain Layer Infrastructure Layer Orchestrates application and domain layer Encapsulates domain and data access Encapsulates infrastructure concerns
  • 7. Bounded Contexts Customer Car Fuel CarRental car rental bounded context Car Wheel Engine Garage garage bounded context Mechanic Damage ~DomainModelCarRental ~DomainModelGarage
  • 8. TYPO3 Event Sourcing Oliver Hader 11/2016 Entities & Value Objects • make the implicit explicit • make validation part of your domain model • example for bank account number • $account-­‐>setIban('CH1504842000000000002');   • $iban  =  new  Iban('CH1504842000000000002');
 $account-­‐>setIban($iban);
  • 9. TYPO3 Event Sourcing Oliver Hader 11/2016 Events • are messages • are modelled in separate classes • concerning something that really happened • used to communicate between components • handle with observer patterns (signal-slot) • $event  =  new  ReplacedBrokenEngineEvent(…);
  • 10. TYPO3 Event Sourcing Oliver Hader 11/2016 CQRS ~basics
  • 11. TYPO3 Event Sourcing Oliver Hader 11/2016 CQS • CQS - Command Query Separation • actually defined by Bertrand Mayer in 1997 • separate processing in domain model into • write model - modify state with command • read model - fetch & represent state with query
  • 12. TYPO3 Event Sourcing Oliver Hader 11/2016 CQRS • CQRS - Command Query Responsibility Segregation • more specific & restrictive by Greg Young • segregation between write store & read store • changes trigger updates in read store • visualization just uses data-transfer objects
  • 14. TYPO3 Event Sourcing Oliver Hader 11/2016 Event Sourcing ~basics
  • 15. TYPO3 Event Sourcing Oliver Hader 11/2016 Event Sourcing • … CQRS continued & in more details • aim to persist events instead of resulting state • event stores provide read/write capabilities • applying all events results to current state again • events are projected into desired formats
  • 16. TYPO3 Event Sourcing Oliver Hader 11/2016 Events & Event Store • events are immutable • cannot be modified • cannot be deleted • legacy events must be handled • event store is consistent • events are retrieved in correct order • there are no gaps in the event history
  • 17. TYPO3 Event Sourcing Oliver Hader 11/2016 Projections • are observers & handle events • interpret and persist events to • MySQL database • filesystem, e.g. HTML • emit notifications, mails • whatever required format
  • 18. TYPO3 Event Sourcing Oliver Hader 11/2016 Materialized View • persist information for accordant requirements • forget about complex JOIN statements • data is represented denormalized • pre-process information for view • read 40 field values vs. just two are shown
  • 19. Event Sourcing Overview Command Handler Command Bus Repository ServiceEventPublisher EventHandler Denormalizer Thin Data Layer Facade Domain DTOs Commands Aggregate Events Events Events Events SQL ClientCommands Queries External Events Internal Events some query results
  • 20. TYPO3 Event Sourcing Oliver Hader 11/2016 Why??? ~basics
  • 21. TYPO3 Data Architecture Repository & Reconstitution Routing Controller View Model Permission Persistence Infrastructure Frontend Extbase Backend EditDocumentController FormEngine <<TCA>> FormDataProvider BackendUserAuthentication DataHandler RelationHandler TypoScriptFrontendController ActionContoller AbstractView AbstractEntity & AbstractValueObject Repository Typo3DbBackend Backend PersistenceManager DataMapper StandaloneView <<custom>> ConnectionPool Connection <<TCA>> AbstractPlugin ContentObjectRenderer FrontendRequestHandler BackendRouteDispatcher BackendRequestHandler MVCDispatcher <<TypoScript>> <<direct database operations>> <<direct database operations>> x x x
  • 22. Localization in TYPO3 DataHandlerController DataHandler RelationHandler DatabaseConnection translate <<create>> localize() copyRecord() <<create>> DataHandler process_datamap() last_insert_id() fetch record record [x]-processDBdata() <<create>> start() fetch references references writeForeignField() update references insert record new_record_id new_record_id new_record_id references new_record_id multipleread&writeprocesses
  • 23. Context & Overlays is translation of uid 13 sys_language_uid 0 :tt_content l10n_parent 0 header Message pid 100 t3ver_wsid 0 t3ver_state 0 t3ver_oid 0 uid 27 sys_language_uid 1 :tt_content l10n_parent 13 header Nachricht pid 100 t3ver_wsid 1 t3ver_state 1 t3ver_oid 0 uid 28 sys_language_uid 1 :tt_content l10n_parent 13 header Nachricht pid -1 t3ver_wsid 1 t3ver_state -1 t3ver_oid 27 uid 41 sys_language_uid 0 :tt_content l10n_parent 0 header News pid -1 t3ver_wsid 1 t3ver_state 0 t3ver_oid 13 is workspace version of is new version is default version is workspace version of is new palceholder
  • 24. TYPO3 Event Sourcing Oliver Hader 11/2016 Why… • is persistence and relation handling different • extbase cannot persist in workspace context • only back-end has permission layer • are context information persisted with each record • are record overlays fetched & applied each time
  • 25. TYPO3 Event Sourcing Oliver Hader 11/2016 bank account example
  • 26. TYPO3 Event Sourcing Oliver Hader 11/2016 Regular approach • using ExtensionBuilder to kick-start model • AccountController - modify & read information • AccountRepository - modify & read information • Account modelled as aggregate root • Transaction model bound to Aggregate (1:n) • using lazy-loading for Transaction entities
  • 27. TYPO3 Event Sourcing Oliver Hader 11/2016 Identify domain events • event storming is a team process • helps to combine knowledge concerning domain • in style of reverse engineering • working backwards • identify events • identify commands that lead to events • identify rules that are applied to commands
  • 29. Bank Account Example debited money debit money account not closed balance sufficient account created deposit money account not closed deposited money create account
  • 30. TYPO3 Event Sourcing Oliver Hader 11/2016 Demo & Source Code • https://github.com/TYPO3Incubator/ bank_account_example • Configuration • CommandController & ManagementController • Domain Commands & Domain Events • EventRepositories & ProjectionRepositories • Projections & Data-Transfer Objects
  • 31. TYPO3 Event Sourcing Oliver Hader 11/2016 generic modelling
  • 32. TYPO3 Event Sourcing Oliver Hader 11/2016 Generic Domain Model • no real models for most core database tables • generic models contain common aspects • identity (”tt_content:123”) • atomic, direct values • relations to other entities • ”generic“ is not domain-driven • but this concept is very useful here
  • 33. TYPO3 Event Sourcing Oliver Hader 11/2016 Generic Domain Events • created, modified, deleted ~CRUD (without R) • moved, duplicated • hidden, shown ~visibility • translated ~language context • branched, merged ~workspace context • attached, removed, ordered relation ~association
  • 34. TYPO3 Event Sourcing Oliver Hader 11/2016 Interceptors • DataHandler ~$tce->process_datamap(); • DatabaseConnection ~INSERT, UPDATE, DELETE • translate actions into generic commands • $GLOBALS['TCA'][…]['ctrl']['eventSourcing']=[
        'listenEvents'  =>  true,
        'recordEvents'  =>  true,
        'projectEvents'  =>  true,
  • 35. TYPO3 Event Sourcing Oliver Hader 11/2016 Command Upgrades • tranlate generic to specific domain commands • delegates domain control back to application • back to bank account example • does not need to implement generic commands • action in back-end form result in real commands
  • 36. TYPO3 Event Sourcing Oliver Hader 11/2016 Context & Local Storage • Materialized View on database-level • workspace and language define specific context • each context uses an individual database • information stored in SQLite locally • projections update for each context • it was named Local Storage
  • 37. Local Storage DEFAULT MySQL - _conn: DriverConnection Connection + select(...arguments[]) + insert(…arguments[]) + update(…arguments[]) + delete(…arguments[]) ORIGIN MySQL - _conn: DriverConnection Connection + select(...arguments[]) + insert(…arguments[]) + update(…arguments[]) + delete(…arguments[]) DefaultConnection LocalStorage workspace-0 SQLite - _conn: DriverConnection Connection + select(...arguments[]) + insert(…arguments[]) + update(…arguments[]) + delete(…arguments[]) DefaultConnection LocalStorage workspace-1 SQLite - _conn: DriverConnection Connection + select(...arguments[]) + insert(…arguments[]) + update(…arguments[]) + delete(…arguments[]) current state future state, context based assigned to assigned to
  • 38. TYPO3 Event Sourcing Oliver Hader 11/2016 Demo & Source Code • https://github.com/TYPO3Incubator/data_handling • Content Editing in back-end • Event Store results • Projections • Command Translations
  • 39. TYPO3 Event Sourcing Oliver Hader 11/2016 opportunities
  • 40. TYPO3 Event Sourcing Oliver Hader 11/2016 Projections! • separation between mutation & presentation • events are the new & only true source • everything else can be projected • … and re-projected if it was wrong • e.g. https://review.typo3.org/#/c/45320/ • trigger index update (Solr, Elasticsearc)
  • 41. TYPO3 Event Sourcing Oliver Hader 11/2016 Questions?
  • 42. TYPO3 Event Sourcing Oliver Hader 11/2016 Sources • Figures • “Layered Architecture“ - Buenosvinos, Carlos, Soronellas, Christian und Akbary, Keyvan. 2016. Domain- Driven Design in PHP. Victoria : Leanpub, 2016. ISBN 9780994608413 • ”CQRS Overview“ - Betts, Dominic, et al. 2013. Exploring CQRS and Event Sourcing. Redmond : Microsoft patterns & practices, 2013. ISBN 9781621140160 • ”Event Sourcing Overview“ - Nijhof, Mark. 2013. CQRS, The example. Victoria : Leanpub, 2013. ISBN 9781484102879 • GitHub source codes • https://github.com/TYPO3Incubator/bank_account_example • https://github.com/TYPO3Incubator/data_handling • Master Thesis on Event Sourcing (German only) • https://get.h4ck3r31.net/T3CRR16-HwWL498EvURCxnnittPoHyNrXkN3xi/ Hader_Oliver_TYPO3_EventSourcing.pdf
  • 43. TYPO3 Event Sourcing Oliver Hader 11/2016 Thank you! ohader
 @ohader
 Oliver_Hader follow mehttps://h4ck3r31.net