SlideShare a Scribd company logo
Pragmatic CQRS
Pragmatic CQRS - Digital Xchange
Lucas Jellema, CTO & Architect at AMIS
Digital Xchange Bergisches Rheinland, May 2019
Lucas Jellema
Architect / Developer
1994 started in IT at Oracle
2002 joined AMIS
Currently CTO & Solution Architect
Pragmatic CQRS - Digital Xchange
BOL - CQRS
Pragmatic CQRS - Digital Xchange
Books Online - WebShop
Pragmatic CQRS - Digital Xchange
Products
Product updates
firewall
Data manipulation
Data Quality (enforcement)
<10K transactions
Batch jobs next to online
Speed is nice
Read only
On line
Speed is crucial
XHTML & JSON
> 5M visits
Webshop visits
- searches
- product details
- Orders
Pragmatic CQRS - Digital Xchange
Products
Products
Products
Webshop visits
- searches
- product details
- Orders
firewall
Data manipulation
Data Quality (enforcement)
<10K transactions
Batch jobs next to online
Speed is nice
Read only
On line
Speed is crucial
XHTML & JSON
> 1M visits
DMZ
Read only
JSON documents
Images
Text Search
Scale Horizontally
Stale but consistent
Products
Nightly generation
Product updates
What is different?
• DML != Query
• Duplication of Data (<> evil)
• Data in multiple physical locations
• ACID is not an absolute truth
• Eventual Consistency
(relaxed freshness)
• NoSQL – not everything is relational
• Data preprocessed, stored
and produced
for a special consumer
• TCO is not a given – and it matters
Pragmatic CQRS - Digital Xchange
Why?
• Performance
• Scalability
• Availability
• Development productivity
• Agility through decoupling
• Reduction in TCO
Pragmatic CQRS - Digital Xchange
Common mechanism for Duplicating Data to improve
performance, scalability and developer productivity
Pragmatic CQRS - Digital Xchange
Many Complex, Heavy
Queries: Complex
Joins, Expensive
Aggregations
Inserts, Updates
and the odd
Delete
Common mechanism for Duplicating Data to improve
performance, scalability and developer productivity
Pragmatic CQRS - Digital Xchange
Many Simple Cheap
Queries
Inserts, Updates
and the odd
Delete
Many Simple Cheap
Queries
Required and feasible
consistency: REFRESH
ON COMMIT
or scheduled refresh
Utility Company looking for Performance, Scalability and
Availability in their core data sets
Pragmatic CQRS - Digital Xchange
CRM
Meter Readings
batch
Invoicing
Billing
Marketing
Campaigns
Load on Core Systems &
effect on Performance
Availability Core Systems
Utility Company looking for Performance, Scalability and
Availability in their core data sets
Pragmatic CQRS - Digital Xchange
CRM
Meter Readings
Invoicing
Billing
Marketing
Campaigns
CRM
Cache DB
Meter
Readings
Cache DB
Utility Company looking for Performance, Scalability and
Availability in their core data sets
Pragmatic CQRS - Digital Xchange
CRM
Meter Readings
Invoicing
Billing
Marketing
Campaigns
CRM
Cache DB
Meter
Readings
Cache DB
Practical Challenges
• Publish all change events
from sources
• Event schema evolution
• Lag in Cache Databases
• “eventual consistency”
• Differences between sources
and cache databases
• Initial creation of Cache Databases
• Scale and event storm
• Business and Mission Critical availability
• Data Authorization
• Logic enforced in source (applications)
• GDPR
Pragmatic CQRS - Digital Xchange
CRM
Meter Readings
Invoicing
Billing
Marketing
Campaigns
CRM Cache
DB
Meter Readings
Cache DB
Pragmatic CQRS - Digital Xchange
Products
Data Manipulation
Data
Retrieval
CQRS
Same Data, Multiple – different – Usage Scenarios
• Different in:
• Why
• What – grain, aggregation, breadth, type of and variation in queries
• How – format, language, accuracy and freshness, consistency
• When – frequency, time of day | week | month, 24/7
• Where – latency, band width, off line
• Who – scale, different roles & user groups
Pragmatic CQRS - Digital Xchange
Pragmatic CQRS - Digital Xchange
Special
Products
Product
Clusters
ProductsData Manipulation
Data Retrieval
Food
Stuff
Toys
Quick Product
Search Index
Product Store in
SaaS app
CQRS: Command Query Responsibility Segregation
Pragmatic CQRS - Digital Xchange
MongoDB
ORDERS
Oracle Database
DVX_ORDERS
Pragmatic CQRS - Digital Xchange
MongoDB
ORDERS
Oracle Database
DVX_ORDERS
Pragmatic CQRS - Digital Xchange
19
MongoDB
ORDERS
Oracle Database
DVX_ORDERS
Pragmatic CQRS - Digital Xchange
µ
µ
20
MongoDB
ORDERS
Oracle Database
DVX_ORDERS
Pragmatic CQRS - Digital Xchange
Special
Products
Product
Clusters
ProductsData Manipulation
Data Retrieval
Food
Stuff
Toys
Quick Product
Search Index
Product Store in
SaaS app
CQRS Steps and Challenges
CQRS Steps and Challenges
Pragmatic CQRS - Digital Xchange
Special
Products
Product Clusters
ProductsData Manipulation
Data Retrieval
Food Stuff
Toys
Quick Product Search
Index
Product Store in
SaaS app
Detect changes
Extract Data
Transport Data
Convert Data
Apply Data
Spot and Handle
Errors
Governance &
Evolution
Enforce Constraints
& Authorization
From C to Q
• How quickly?
• How frequently?
• How reliably?
• How atomically?
•
Pragmatic CQRS - Digital Xchange
Products
Quick Product Search
Index
Pragmatic CQRS - Digital Xchange
From C to Q
• How quickly?
• How frequently?
• How reliably?
• How atomic?
•
• Data Authorization Considerations
• Locations & Connectivity
• Full resynch | restore of Query Store
Pragmatic CQRS - Digital Xchange
Products
Quick Product Search
Index
Typical CQRS Architecture
Pragmatic CQRS - Digital Xchange
Event Platform
Source systems
Poll
Consume
Detect &
Retrieve
Change
Change Reporters Distributed Change Event Hub Change Projectors Destination systems
Transform
& Apply
(re)Calculate
& Record
Convert,
Translate,
StoreEvent Schema
Governance
Monitoring & Error Handling
Technologies to support CQRS
• Detecting and Extracting and Publishing Changes
• Database specific change detection
• Debezium, Kafka Connect, SOA Suite Inbound Adapters,
• Cloud Adapters in iPaaS platforms and SaaS products
• Decoupled gathering & queueing of change events (preferably distributed
and technology agnostic; options for long term event retention)
• Kafka, Rabbit MQ, AWS SQS, JMS
• Handling change – transport, transform, apply
• Query Stores – picked based on data use case requirement, not for CQRS
• Any database, in memory cache
Pragmatic CQRS - Digital Xchange
Detecting and Extracting and Publishing Changes
Oracle Database as source
• Oracle GoldenGate, Oracle Data Integrator
• Data Integration Platform Cloud
• SOA Suite Inbound Database Adapter
• Custom:
• Polling
• Log Mining
• Triggers (publishing DML change events)
• Record in Table or AQ/JMS
• Push over HTTP
• Write to file
• Materialized View (Log)
• Flashback Query
• Continuous Query Notification (DB QRCN)
• To PL/SQL package or Java application
Pragmatic CQRS - Digital Xchange
Poll
Consume
Detect &
Retrieve
Change
Detecting and Extracting and Publishing Changes from
many sources – Debezium, Kafka Connect, Apache Kafka
Pragmatic CQRS - Digital Xchange
CDC
Debezium
Apache Kafka
iPaaS (Cloud) Adapters for SaaS & Platform
• Prepackaged Change Event Detectors
Pragmatic CQRS - Digital Xchange
JIT vs AOT
Pragmatic CQRS - Digital Xchange
Ahead of Time
• Prepare products Ahead of Time instead of upon request
• When the time to deliver (to request) is too long
• When the complexity of a JIT-approach is too high
• When the capacity does not allow for JIT-peak production
• When the overhead and waste of AOT are justified
Pragmatic CQRS - Digital Xchange
JIT vs AOT Data Integration
• JIT
• Process [synchronous] request for data ‘just in in time’
• Only data that is requested
• Fresh as can be
• All authorization rules applied
• Single Source of Truth
• Transformation & Aggregation at request time
• Hard (runtime) dependencies from consumer on producer
• AOT
• Pre-process / pre-share data ‘ahead of time’
• Potentially includes data that will never be requested
• Data can be outdated
Pragmatic CQRS - Digital Xchange
Backend For Frontend
Pragmatic CQRS - Digital Xchange
CQRS => Data Backend For Frontend:
Optimized data set for special use case
• Shape & Format
• Right Grained (aggregation, consolidation)
• Filtered
• Enriched (from multiple sources)
• Location
• Time (refreshed at the right time)
• Search Options
• BASE (eventually – when? – consistent)
• Authorization
• GDPR
Pragmatic CQRS - Digital Xchange
UI
APIs
(backend for
frontend)
Data Store
Master
Database
Domain Driven Design
Pragmatic CQRS - Digital Xchange
• Context Mapping and Bounded Context
• Ubiquitous Language
• Microservices
• Domain Events
• Anti Corruption Layer (ACL)
• Autonomous Bubble pattern
Final Demo
• Microservice
Pragmatic CQRS - Digital Xchange
Microservices
• Agile | Flexible | Scalable | (Re)Deployable
• Independent | Decoupled | Isolated
• Communicate asynchronously, via events
• Have their own private bounded context
– the data they require to function
• Their lifeblood
Pragmatic CQRS - Digital Xchange
Microservices State
Cache
RDBMS
Document
Store
NoSQL
Generic Platform for running microservices
Event Hub
Big Data
Block
Storage
LDAP
Pragmatic CQRS - Digital Xchange
Bounded context of microservices
• A micoservice needs to be able to run independently
• It needs to contain & own all data required to run
• It cannot depend on other microservices
API
Customer
APIUI
OrderCustomerModified event
Pragmatic CQRS - Digital Xchange
Autonomous Bubble pattern in DDD
• Getting started with Domain Driven Design in the context of Legacy
Systems
• Synchronizing Anti Corruption Layer
• Translate anything that crosses a context boundary
Pragmatic CQRS - Digital Xchange
Autonomous Bubble pattern in DDD
Pragmatic CQRS - Digital Xchange
Legacy
New Application
Other Context
Autonomous Bubble pattern in DDD
Pragmatic CQRS - Digital Xchange
Legacy
New Application
Other Context
Event
Publisher
Event
Publisher
Q
Q
Q
Coordinator
consume
Event Sourcing
Pragmatic CQRS - Digital Xchange
Utility Company: Rebuild Cache Database
Pragmatic CQRS - Digital Xchange
CRM
Meter Readings
CRM
Cache DB
Meter
Readings
Cache DB
Utility Company: Rebuild Cache Database
From Event Store
Pragmatic CQRS - Digital Xchange
CRM
Cache DB
Meter
Readings
Cache DB
Event Sourcing Driving CQRS
Pragmatic CQRS - Digital Xchange
Events Event Store
Current State
accountId:
123
amount: 10
Owner: Jane Doe
Event Sourcing Driving CQRS
Pragmatic CQRS - Digital Xchange
Events Event Store
Current State
Other State Aggregate
Event Sourcing
• Event Store is immutable – append-only log of domain state transitions
• Replay events
• to (re)construct a representation of the current state (aggregate)
• up to a specific time to recreate moments in time
• in Test environment to investigate an issue
• on a remote location to create mirror & share state across boundaries
• produce a fine grained audit trail
• Challenges
• Time required to reconstruct state
• Grain of aggregates / definition of domain events
Pragmatic CQRS - Digital Xchange
Distributed Database with Event Sourcing & Current State
Pragmatic CQRS - Digital Xchange
World State
Collective Data Set
and
Equal Data Position
Pragmatic CQRS - Digital Xchange
Industrial Data Space
Pragmatic CQRS - Digital Xchange
Data Sharing Ecosystems
• Multiple independent
organizations
• Mutually benefit from
having access to
the same data
at the same time
• Share data & Have access to data with minimum of overhead and with equality among the
ecosystem partners
• Partners are on different network domains, physical locations, technology stacks, …
• New Partners can join
• Partners can leave
• Consensus on what constitutes correct data
Pragmatic CQRS - Digital Xchange
Collective Dataset
Pragmatic CQRS - Digital Xchange
Company
A
Company
C
Company
D
Company
E
Company
F
Collective
Dataset
Company
B
Collective Dataset
Pragmatic CQRS - Digital Xchange
Company
A
Company
C
Company
D
Company
E
Company
F Central
Database
Enterprise
Service Bus
Canonical SOAP WS/
REST API for Sending
Inserts/Updates/Deletes
and for Requesting
current data
Just In Time Integration
Company
B
Collective Dataset = Collective Data Change Events
Pragmatic CQRS - Digital Xchange
Company
A
Company
C
Company
D
Company
E
Company
F
Central
Event
Platform Interfaces for Publishing
and Consuming Events
Note: events can be
consumed
asynchronously
Ahead of Time Integration
Company
B
Collective Dataset => Collective Data Store
Pragmatic CQRS - Digital Xchange
Company
A
Company
C
Company
D
Company
E
Company
F
Ahead of Time Integration
Company
B
Summary
• Why: very different data usage patterns
• What: provide tailored query channels for
usage patterns (Backend for Frontend)
• How: replicate data from source datastore
to query store – with appropriate format,
grain-level, scalability, location, availability, query options
• When: source database(s) cannot fulfil non-functional requirements
• With: change detectors & publishers, event platform, change projectors and
governance on event definitions, monitoring & error handling
• Challenges: scale, speed, consistency, authorization, initial build & full
rebuild
• Benefits: performance at scale, availability, developer productivity, agility,
lower TCO and …
Pragmatic CQRS - Digital Xchange
Contact Details
Pragmatic CQRS - Digital Xchange
• Blog: technology.amis.nl
• Email: lucas.jellema@amis.nl
• : lucasjellema
• : lucas-jellema
• : www.amis.nl, info@amis.nl
+31 306016000
Edisonbaan 15,
Nieuwegein

More Related Content

What's hot (20)

PDF
한컴MDS_국산 RTOS NEOS 제품 및 적용 사례
HANCOM MDS
 
PDF
Database security issues
n|u - The Open Security Community
 
PPTX
Concurrency Control in Database Management System
Janki Shah
 
PPT
4. concurrency control
AbDul ThaYyal
 
PPT
Relational model
WBUTTUTORIALS
 
PPTX
Mandatory access control for information security
Ajit Dadresa
 
PPT
12 symmetric key cryptography
drewz lin
 
PPTX
Symmetric encryption and message confidentiality
CAS
 
PDF
Public key Infrastructure (PKI)
Venkatesh Jambulingam
 
PPTX
Rotor machine,subsitution technique
kirupasuchi1996
 
PPTX
Query processing
Dr. C.V. Suresh Babu
 
PPTX
Object oriented database concepts
Temesgenthanks
 
PPT
Applet Architecture - Introducing Java Applets
amitksaha
 
POTX
Stream Ciphers
SHUBHA CHATURVEDI
 
PPT
Conventional Encryption NS2
koolkampus
 
PPT
System call
Sumant Diwakar
 
DOCX
Concurrency Control Techniques
Raj vardhan
 
PPTX
Clustering for Stream and Parallelism (DATA ANALYTICS)
DheerajPachauri
 
PPT
distributed shared memory
Ashish Kumar
 
한컴MDS_국산 RTOS NEOS 제품 및 적용 사례
HANCOM MDS
 
Database security issues
n|u - The Open Security Community
 
Concurrency Control in Database Management System
Janki Shah
 
4. concurrency control
AbDul ThaYyal
 
Relational model
WBUTTUTORIALS
 
Mandatory access control for information security
Ajit Dadresa
 
12 symmetric key cryptography
drewz lin
 
Symmetric encryption and message confidentiality
CAS
 
Public key Infrastructure (PKI)
Venkatesh Jambulingam
 
Rotor machine,subsitution technique
kirupasuchi1996
 
Query processing
Dr. C.V. Suresh Babu
 
Object oriented database concepts
Temesgenthanks
 
Applet Architecture - Introducing Java Applets
amitksaha
 
Stream Ciphers
SHUBHA CHATURVEDI
 
Conventional Encryption NS2
koolkampus
 
System call
Sumant Diwakar
 
Concurrency Control Techniques
Raj vardhan
 
Clustering for Stream and Parallelism (DATA ANALYTICS)
DheerajPachauri
 
distributed shared memory
Ashish Kumar
 

Similar to Pragmatic CQRS with existing applications and databases (Digital Xchange, May 2019) (20)

PPTX
CQRS introduction
Yura Taras
 
PPTX
CQRS innovations (English version)
Andrey Lomakin
 
PPTX
Patterns of Distributed Application Design
Orkhan Gasimov
 
KEY
Event Driven Architecture
andreaskallberg
 
PDF
Event Driven-Architecture from a Scalability perspective
Jonas Bonér
 
PDF
CDC patterns in Apache Kafka®
confluent
 
PPTX
Hofstra University - Overview of Big Data
sarasioux
 
PDF
Events and microservices
Saul Caganoff
 
PDF
Raleigh Kafka Meetup - DDD, ES, and CQRS
Jeff Dutton
 
PPTX
Stream me to the Cloud (and back) with Confluent & MongoDB
confluent
 
PDF
Patterns of Distributed Application Design
GlobalLogic Ukraine
 
PDF
CQRS - Eine Einführung - NOUG 2011
Dennis Traub
 
PDF
CQRS + Event Sourcing
Mike Bild
 
PPTX
Events & Microservices
Yamen Sader
 
PDF
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
PPTX
Brown bag eventdrivenmicroservices-cqrs
Vikash Kodati
 
PPTX
Our way to microservices
Andi Pangeran
 
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
PPTX
Cqrs and Event Sourcing Intro For Developers
wojtek_s
 
PPTX
Lets focus on business value
Einar Ingebrigtsen
 
CQRS introduction
Yura Taras
 
CQRS innovations (English version)
Andrey Lomakin
 
Patterns of Distributed Application Design
Orkhan Gasimov
 
Event Driven Architecture
andreaskallberg
 
Event Driven-Architecture from a Scalability perspective
Jonas Bonér
 
CDC patterns in Apache Kafka®
confluent
 
Hofstra University - Overview of Big Data
sarasioux
 
Events and microservices
Saul Caganoff
 
Raleigh Kafka Meetup - DDD, ES, and CQRS
Jeff Dutton
 
Stream me to the Cloud (and back) with Confluent & MongoDB
confluent
 
Patterns of Distributed Application Design
GlobalLogic Ukraine
 
CQRS - Eine Einführung - NOUG 2011
Dennis Traub
 
CQRS + Event Sourcing
Mike Bild
 
Events & Microservices
Yamen Sader
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Brown bag eventdrivenmicroservices-cqrs
Vikash Kodati
 
Our way to microservices
Andi Pangeran
 
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Cqrs and Event Sourcing Intro For Developers
wojtek_s
 
Lets focus on business value
Einar Ingebrigtsen
 
Ad

More from Lucas Jellema (20)

PPTX
Introduction to web application development with Vue (for absolute beginners)...
Lucas Jellema
 
PPTX
Making the Shift Left - Bringing Ops to Dev before bringing applications to p...
Lucas Jellema
 
PPTX
Lightweight coding in powerful Cloud Development Environments (DigitalXchange...
Lucas Jellema
 
PPTX
Apache Superset - open source data exploration and visualization (Conclusion ...
Lucas Jellema
 
PPTX
CONNECTING THE REAL WORLD TO ENTERPRISE IT – HOW IoT DRIVES OUR ENERGY TRANSI...
Lucas Jellema
 
PPTX
Help me move away from Oracle - or not?! (Oracle Community Tour EMEA - LVOUG...
Lucas Jellema
 
PPTX
Op je vingers tellen... tot 1000!
Lucas Jellema
 
PPTX
IoT - from prototype to enterprise platform (DigitalXchange 2022)
Lucas Jellema
 
PPTX
Who Wants to Become an IT Architect-A Look at the Bigger Picture - DigitalXch...
Lucas Jellema
 
PPTX
Steampipe - use SQL to retrieve data from cloud, platforms and files (Code Ca...
Lucas Jellema
 
PPTX
Automation of Software Engineering with OCI DevOps Build and Deployment Pipel...
Lucas Jellema
 
PPTX
Introducing Dapr.io - the open source personal assistant to microservices and...
Lucas Jellema
 
PPTX
How and Why you can and should Participate in Open Source Projects (AMIS, Sof...
Lucas Jellema
 
PPTX
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Lucas Jellema
 
PPTX
Microservices, Node, Dapr and more - Part One (Fontys Hogeschool, Spring 2022)
Lucas Jellema
 
PPTX
6Reinventing Oracle Systems in a Cloudy World (RMOUG Trainingdays, February 2...
Lucas Jellema
 
PPTX
Help me move away from Oracle! (RMOUG Training Days 2022, February 2022)
Lucas Jellema
 
PPTX
Tech Talks 101 - DevOps (jan 2022)
Lucas Jellema
 
PPTX
Conclusion Code Cafe - Microcks for Mocking and Testing Async APIs (January 2...
Lucas Jellema
 
PPTX
Cloud Native Application Development - build fast, low TCO, scalable & agile ...
Lucas Jellema
 
Introduction to web application development with Vue (for absolute beginners)...
Lucas Jellema
 
Making the Shift Left - Bringing Ops to Dev before bringing applications to p...
Lucas Jellema
 
Lightweight coding in powerful Cloud Development Environments (DigitalXchange...
Lucas Jellema
 
Apache Superset - open source data exploration and visualization (Conclusion ...
Lucas Jellema
 
CONNECTING THE REAL WORLD TO ENTERPRISE IT – HOW IoT DRIVES OUR ENERGY TRANSI...
Lucas Jellema
 
Help me move away from Oracle - or not?! (Oracle Community Tour EMEA - LVOUG...
Lucas Jellema
 
Op je vingers tellen... tot 1000!
Lucas Jellema
 
IoT - from prototype to enterprise platform (DigitalXchange 2022)
Lucas Jellema
 
Who Wants to Become an IT Architect-A Look at the Bigger Picture - DigitalXch...
Lucas Jellema
 
Steampipe - use SQL to retrieve data from cloud, platforms and files (Code Ca...
Lucas Jellema
 
Automation of Software Engineering with OCI DevOps Build and Deployment Pipel...
Lucas Jellema
 
Introducing Dapr.io - the open source personal assistant to microservices and...
Lucas Jellema
 
How and Why you can and should Participate in Open Source Projects (AMIS, Sof...
Lucas Jellema
 
Microservices, Apache Kafka, Node, Dapr and more - Part Two (Fontys Hogeschoo...
Lucas Jellema
 
Microservices, Node, Dapr and more - Part One (Fontys Hogeschool, Spring 2022)
Lucas Jellema
 
6Reinventing Oracle Systems in a Cloudy World (RMOUG Trainingdays, February 2...
Lucas Jellema
 
Help me move away from Oracle! (RMOUG Training Days 2022, February 2022)
Lucas Jellema
 
Tech Talks 101 - DevOps (jan 2022)
Lucas Jellema
 
Conclusion Code Cafe - Microcks for Mocking and Testing Async APIs (January 2...
Lucas Jellema
 
Cloud Native Application Development - build fast, low TCO, scalable & agile ...
Lucas Jellema
 
Ad

Recently uploaded (20)

PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
Top Agile Project Management Tools for Teams in 2025
Orangescrum
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 

Pragmatic CQRS with existing applications and databases (Digital Xchange, May 2019)

  • 1. Pragmatic CQRS Pragmatic CQRS - Digital Xchange Lucas Jellema, CTO & Architect at AMIS Digital Xchange Bergisches Rheinland, May 2019
  • 2. Lucas Jellema Architect / Developer 1994 started in IT at Oracle 2002 joined AMIS Currently CTO & Solution Architect Pragmatic CQRS - Digital Xchange
  • 3. BOL - CQRS Pragmatic CQRS - Digital Xchange
  • 4. Books Online - WebShop Pragmatic CQRS - Digital Xchange Products Product updates firewall Data manipulation Data Quality (enforcement) <10K transactions Batch jobs next to online Speed is nice Read only On line Speed is crucial XHTML & JSON > 5M visits Webshop visits - searches - product details - Orders
  • 5. Pragmatic CQRS - Digital Xchange Products Products Products Webshop visits - searches - product details - Orders firewall Data manipulation Data Quality (enforcement) <10K transactions Batch jobs next to online Speed is nice Read only On line Speed is crucial XHTML & JSON > 1M visits DMZ Read only JSON documents Images Text Search Scale Horizontally Stale but consistent Products Nightly generation Product updates
  • 6. What is different? • DML != Query • Duplication of Data (<> evil) • Data in multiple physical locations • ACID is not an absolute truth • Eventual Consistency (relaxed freshness) • NoSQL – not everything is relational • Data preprocessed, stored and produced for a special consumer • TCO is not a given – and it matters Pragmatic CQRS - Digital Xchange
  • 7. Why? • Performance • Scalability • Availability • Development productivity • Agility through decoupling • Reduction in TCO Pragmatic CQRS - Digital Xchange
  • 8. Common mechanism for Duplicating Data to improve performance, scalability and developer productivity Pragmatic CQRS - Digital Xchange Many Complex, Heavy Queries: Complex Joins, Expensive Aggregations Inserts, Updates and the odd Delete
  • 9. Common mechanism for Duplicating Data to improve performance, scalability and developer productivity Pragmatic CQRS - Digital Xchange Many Simple Cheap Queries Inserts, Updates and the odd Delete Many Simple Cheap Queries Required and feasible consistency: REFRESH ON COMMIT or scheduled refresh
  • 10. Utility Company looking for Performance, Scalability and Availability in their core data sets Pragmatic CQRS - Digital Xchange CRM Meter Readings batch Invoicing Billing Marketing Campaigns Load on Core Systems & effect on Performance Availability Core Systems
  • 11. Utility Company looking for Performance, Scalability and Availability in their core data sets Pragmatic CQRS - Digital Xchange CRM Meter Readings Invoicing Billing Marketing Campaigns CRM Cache DB Meter Readings Cache DB
  • 12. Utility Company looking for Performance, Scalability and Availability in their core data sets Pragmatic CQRS - Digital Xchange CRM Meter Readings Invoicing Billing Marketing Campaigns CRM Cache DB Meter Readings Cache DB
  • 13. Practical Challenges • Publish all change events from sources • Event schema evolution • Lag in Cache Databases • “eventual consistency” • Differences between sources and cache databases • Initial creation of Cache Databases • Scale and event storm • Business and Mission Critical availability • Data Authorization • Logic enforced in source (applications) • GDPR Pragmatic CQRS - Digital Xchange CRM Meter Readings Invoicing Billing Marketing Campaigns CRM Cache DB Meter Readings Cache DB
  • 14. Pragmatic CQRS - Digital Xchange Products Data Manipulation Data Retrieval CQRS
  • 15. Same Data, Multiple – different – Usage Scenarios • Different in: • Why • What – grain, aggregation, breadth, type of and variation in queries • How – format, language, accuracy and freshness, consistency • When – frequency, time of day | week | month, 24/7 • Where – latency, band width, off line • Who – scale, different roles & user groups Pragmatic CQRS - Digital Xchange
  • 16. Pragmatic CQRS - Digital Xchange Special Products Product Clusters ProductsData Manipulation Data Retrieval Food Stuff Toys Quick Product Search Index Product Store in SaaS app CQRS: Command Query Responsibility Segregation
  • 17. Pragmatic CQRS - Digital Xchange MongoDB ORDERS Oracle Database DVX_ORDERS
  • 18. Pragmatic CQRS - Digital Xchange MongoDB ORDERS Oracle Database DVX_ORDERS
  • 19. Pragmatic CQRS - Digital Xchange 19 MongoDB ORDERS Oracle Database DVX_ORDERS
  • 20. Pragmatic CQRS - Digital Xchange µ µ 20 MongoDB ORDERS Oracle Database DVX_ORDERS
  • 21. Pragmatic CQRS - Digital Xchange Special Products Product Clusters ProductsData Manipulation Data Retrieval Food Stuff Toys Quick Product Search Index Product Store in SaaS app CQRS Steps and Challenges
  • 22. CQRS Steps and Challenges Pragmatic CQRS - Digital Xchange Special Products Product Clusters ProductsData Manipulation Data Retrieval Food Stuff Toys Quick Product Search Index Product Store in SaaS app Detect changes Extract Data Transport Data Convert Data Apply Data Spot and Handle Errors Governance & Evolution Enforce Constraints & Authorization
  • 23. From C to Q • How quickly? • How frequently? • How reliably? • How atomically? • Pragmatic CQRS - Digital Xchange Products Quick Product Search Index
  • 24. Pragmatic CQRS - Digital Xchange
  • 25. From C to Q • How quickly? • How frequently? • How reliably? • How atomic? • • Data Authorization Considerations • Locations & Connectivity • Full resynch | restore of Query Store Pragmatic CQRS - Digital Xchange Products Quick Product Search Index
  • 26. Typical CQRS Architecture Pragmatic CQRS - Digital Xchange Event Platform Source systems Poll Consume Detect & Retrieve Change Change Reporters Distributed Change Event Hub Change Projectors Destination systems Transform & Apply (re)Calculate & Record Convert, Translate, StoreEvent Schema Governance Monitoring & Error Handling
  • 27. Technologies to support CQRS • Detecting and Extracting and Publishing Changes • Database specific change detection • Debezium, Kafka Connect, SOA Suite Inbound Adapters, • Cloud Adapters in iPaaS platforms and SaaS products • Decoupled gathering & queueing of change events (preferably distributed and technology agnostic; options for long term event retention) • Kafka, Rabbit MQ, AWS SQS, JMS • Handling change – transport, transform, apply • Query Stores – picked based on data use case requirement, not for CQRS • Any database, in memory cache Pragmatic CQRS - Digital Xchange
  • 28. Detecting and Extracting and Publishing Changes Oracle Database as source • Oracle GoldenGate, Oracle Data Integrator • Data Integration Platform Cloud • SOA Suite Inbound Database Adapter • Custom: • Polling • Log Mining • Triggers (publishing DML change events) • Record in Table or AQ/JMS • Push over HTTP • Write to file • Materialized View (Log) • Flashback Query • Continuous Query Notification (DB QRCN) • To PL/SQL package or Java application Pragmatic CQRS - Digital Xchange Poll Consume Detect & Retrieve Change
  • 29. Detecting and Extracting and Publishing Changes from many sources – Debezium, Kafka Connect, Apache Kafka Pragmatic CQRS - Digital Xchange CDC Debezium Apache Kafka
  • 30. iPaaS (Cloud) Adapters for SaaS & Platform • Prepackaged Change Event Detectors Pragmatic CQRS - Digital Xchange
  • 31. JIT vs AOT Pragmatic CQRS - Digital Xchange
  • 32. Ahead of Time • Prepare products Ahead of Time instead of upon request • When the time to deliver (to request) is too long • When the complexity of a JIT-approach is too high • When the capacity does not allow for JIT-peak production • When the overhead and waste of AOT are justified Pragmatic CQRS - Digital Xchange
  • 33. JIT vs AOT Data Integration • JIT • Process [synchronous] request for data ‘just in in time’ • Only data that is requested • Fresh as can be • All authorization rules applied • Single Source of Truth • Transformation & Aggregation at request time • Hard (runtime) dependencies from consumer on producer • AOT • Pre-process / pre-share data ‘ahead of time’ • Potentially includes data that will never be requested • Data can be outdated Pragmatic CQRS - Digital Xchange
  • 34. Backend For Frontend Pragmatic CQRS - Digital Xchange
  • 35. CQRS => Data Backend For Frontend: Optimized data set for special use case • Shape & Format • Right Grained (aggregation, consolidation) • Filtered • Enriched (from multiple sources) • Location • Time (refreshed at the right time) • Search Options • BASE (eventually – when? – consistent) • Authorization • GDPR Pragmatic CQRS - Digital Xchange UI APIs (backend for frontend) Data Store Master Database
  • 36. Domain Driven Design Pragmatic CQRS - Digital Xchange • Context Mapping and Bounded Context • Ubiquitous Language • Microservices • Domain Events • Anti Corruption Layer (ACL) • Autonomous Bubble pattern
  • 37. Final Demo • Microservice Pragmatic CQRS - Digital Xchange
  • 38. Microservices • Agile | Flexible | Scalable | (Re)Deployable • Independent | Decoupled | Isolated • Communicate asynchronously, via events • Have their own private bounded context – the data they require to function • Their lifeblood Pragmatic CQRS - Digital Xchange
  • 39. Microservices State Cache RDBMS Document Store NoSQL Generic Platform for running microservices Event Hub Big Data Block Storage LDAP Pragmatic CQRS - Digital Xchange
  • 40. Bounded context of microservices • A micoservice needs to be able to run independently • It needs to contain & own all data required to run • It cannot depend on other microservices API Customer APIUI OrderCustomerModified event Pragmatic CQRS - Digital Xchange
  • 41. Autonomous Bubble pattern in DDD • Getting started with Domain Driven Design in the context of Legacy Systems • Synchronizing Anti Corruption Layer • Translate anything that crosses a context boundary Pragmatic CQRS - Digital Xchange
  • 42. Autonomous Bubble pattern in DDD Pragmatic CQRS - Digital Xchange Legacy New Application Other Context
  • 43. Autonomous Bubble pattern in DDD Pragmatic CQRS - Digital Xchange Legacy New Application Other Context Event Publisher Event Publisher Q Q Q Coordinator consume
  • 44. Event Sourcing Pragmatic CQRS - Digital Xchange
  • 45. Utility Company: Rebuild Cache Database Pragmatic CQRS - Digital Xchange CRM Meter Readings CRM Cache DB Meter Readings Cache DB
  • 46. Utility Company: Rebuild Cache Database From Event Store Pragmatic CQRS - Digital Xchange CRM Cache DB Meter Readings Cache DB
  • 47. Event Sourcing Driving CQRS Pragmatic CQRS - Digital Xchange Events Event Store Current State accountId: 123 amount: 10 Owner: Jane Doe
  • 48. Event Sourcing Driving CQRS Pragmatic CQRS - Digital Xchange Events Event Store Current State Other State Aggregate
  • 49. Event Sourcing • Event Store is immutable – append-only log of domain state transitions • Replay events • to (re)construct a representation of the current state (aggregate) • up to a specific time to recreate moments in time • in Test environment to investigate an issue • on a remote location to create mirror & share state across boundaries • produce a fine grained audit trail • Challenges • Time required to reconstruct state • Grain of aggregates / definition of domain events Pragmatic CQRS - Digital Xchange
  • 50. Distributed Database with Event Sourcing & Current State Pragmatic CQRS - Digital Xchange World State
  • 51. Collective Data Set and Equal Data Position Pragmatic CQRS - Digital Xchange
  • 52. Industrial Data Space Pragmatic CQRS - Digital Xchange
  • 53. Data Sharing Ecosystems • Multiple independent organizations • Mutually benefit from having access to the same data at the same time • Share data & Have access to data with minimum of overhead and with equality among the ecosystem partners • Partners are on different network domains, physical locations, technology stacks, … • New Partners can join • Partners can leave • Consensus on what constitutes correct data Pragmatic CQRS - Digital Xchange
  • 54. Collective Dataset Pragmatic CQRS - Digital Xchange Company A Company C Company D Company E Company F Collective Dataset Company B
  • 55. Collective Dataset Pragmatic CQRS - Digital Xchange Company A Company C Company D Company E Company F Central Database Enterprise Service Bus Canonical SOAP WS/ REST API for Sending Inserts/Updates/Deletes and for Requesting current data Just In Time Integration Company B
  • 56. Collective Dataset = Collective Data Change Events Pragmatic CQRS - Digital Xchange Company A Company C Company D Company E Company F Central Event Platform Interfaces for Publishing and Consuming Events Note: events can be consumed asynchronously Ahead of Time Integration Company B
  • 57. Collective Dataset => Collective Data Store Pragmatic CQRS - Digital Xchange Company A Company C Company D Company E Company F Ahead of Time Integration Company B
  • 58. Summary • Why: very different data usage patterns • What: provide tailored query channels for usage patterns (Backend for Frontend) • How: replicate data from source datastore to query store – with appropriate format, grain-level, scalability, location, availability, query options • When: source database(s) cannot fulfil non-functional requirements • With: change detectors & publishers, event platform, change projectors and governance on event definitions, monitoring & error handling • Challenges: scale, speed, consistency, authorization, initial build & full rebuild • Benefits: performance at scale, availability, developer productivity, agility, lower TCO and … Pragmatic CQRS - Digital Xchange
  • 59. Contact Details Pragmatic CQRS - Digital Xchange • Blog: technology.amis.nl • Email: [email protected] • : lucasjellema • : lucas-jellema • : www.amis.nl, [email protected] +31 306016000 Edisonbaan 15, Nieuwegein

Editor's Notes

  • #17: Data manipulation and retrieval in separate places (physical data proliferation) Query store is optimized for consumers Level of detail, format, filters applied For performance and scalability, independence, productivity lower license fees and lower TCO, security
  • #22: Data manipulation and retrieval in separate places (physical data proliferation) Query store is optimized for consumers Level of detail, format, filters applied For performance and scalability, independence, productivity lower license fees and lower TCO, security
  • #23: No Event Sourcing No events (?) No green field Packages Applications/SaaS Databases (RDBMS, NoSQL) getting changes from applications directly Challenges – at scale, with enough speed and consistently: do not let query store get into an exposed state that could not exist/be right! Detect relevant changes Extract relevant changes Transport Convert Apply in correct order and reliably (no lost events) Note: after detect and extract, an event can be published
  • #27: Destination system: can be cache, or even only the programmatic representation – without any data duplication Dumb pipes, smart end points
  • #30: MySQL: binlog; Postgres: wnte-ahead log; MongoDB op log
  • #31: AnyPoint Zapier SSI OIC Dell Boomi
  • #40: All data stores are distributed Or at least distributedly available They can be local or on cloud (latency is important) Data in generic data store is still owned by only one microservice – no one can touch it Only in DWH and BigData do we deliberately take copies of data and disown them
  • #43: http://domainlanguage.com/wp-content/uploads/2016/04/GettingStartedWithDDDWhenSurroundedByLegacySystemsV1.pdf
  • #49: Events are immutable facts Current state (active record) is derived from sum of events Read optimized aggregates are created for specific use case – based on events and rebuildable at any time
  • #50: Events are immutable facts Current state (active record) is derived from sum of events Read optimized aggregates are created for specific use case – based on events and rebuildable at any time
  • #52: Blockchain!
  • #56: Central Database plus ESB plus send updates and request data?
  • #57: Central Database plus ESB plus send updates and request data?
  • #58: Central Database plus ESB plus send updates and request data?
  • #59: Central Database plus ESB plus send updates and request data?