SlideShare uma empresa Scribd logo
1 de 46
An introduction to CQRS and Axon Framework 
Finance’s ‘forgotten’ treasure 
Allard Buijze – allard.buijze@trifork.nl
Watch the video with slide 
synchronization on InfoQ.com! 
http://www.infoq.com/presentations 
/cqrs-axon 
InfoQ.com: News & Community Site 
• 750,000 unique visitors/month 
• Published in 4 languages (English, Chinese, Japanese and Brazilian 
Portuguese) 
• Post content from our QCon conferences 
• News 15-20 / week 
• Articles 3-4 / week 
• Presentations (videos) 12-15 / week 
• Interviews 2-3 / week 
• Books 1 / month
Presented at QCon London 
www.qconlondon.com 
Purpose of QCon 
- to empower software development by facilitating the spread of 
knowledge and innovation 
Strategy 
- practitioner-driven conference designed for YOU: influencers of 
change and innovation in your teams 
- speakers and topics driving the evolution and innovation 
- connecting and catalyzing the influencers and innovators 
Highlights 
- attended by more than 12,000 delegates since 2007 
- held in 9 cities worldwide
Allard Buijze 
! Software Architect at Trifork Amsterdam 
! ~ 15 years of web development experience 
! Strong believer in DDD and CQRS 
! Developer and initiator of Axon Framework 
! Java Framework for scalability and performance 
! www.axonframework.org
Layered architecture
Evolution of a Domain Model
Evolution of a Domain Model
Evolution of a Domain Model
Evolution of complexity 
Source: 
h*p://royal.pingdom.com/2008/01/09/the-­‐worst-­‐cable-­‐mess-­‐ever/
Evolution of complexity 
private static final String PLAYER_COCKPIT_WATERFALL_ITEMS_QUERY = 
"(" + 
"select id, " + EntityType.NEWS_ITEM.ordinal() + " as entity_type, publish_date as sort_date " + 
"from news_item " + 
"where active = true and (" + 
NEWS_ITEM 
SELECT 
"poster_player_id = :playerId " + 
"or poster_player_id in (" + 
or 
"select destination_project 
friend_id from in 
friendship (… 
where origin_friend_id = :playerId " + 
") " + 
"or project_id in (" + 
"select distinct project_id " + 
or 
"from donation project 
" + 
in 
(… 
"where donor_participant_id = :playerId and status = 'OK'" + 
")" + 
"or project_id in (" + 
"select project_id from ambassador_project where player_id = :playerId " + 
"))" + 
UNION 
ALL 
DONATION 
status 
= 
‘OK’ 
status 
= 
‘OK’ 
") union all (" + 
"select id, " + EntityType.DONATION.ordinal() + " as entity_type, approval_date as sort_date " + 
"from donation " + 
"where status = 'OK' and (" + 
"donor_participant_id = :playerId " + 
"or donor_participant_id in (" + 
"select destination_friend_id from friendship where origin_friend_id = :playerId" + 
")" + 
"or raised_via_player_id = :playerId " + 
"or raised_via_player_id in (" + 
"select destination_friend_id from friendship where origin_friend_id = :playerId" + 
") " + 
") " + 
or 
raised_via_player 
in 
(… 
UNION 
ALL 
FRIENDSHIP 
") union all ( " + 
"select id, " + EntityType.FRIENDSHIP.ordinal() + " as entity_type, created as sort_date " + 
"from friendship " + 
"where origin_friend_id = :playerId or (origin_friend_id in ( " + 
"select destination_friend_id from friendship where origin_friend_id = :playerId " + 
") and destination_friend_id <> :playerId)" + 
") ";
Layered architecture 
Web 
Cache 
Session 
replicaYon 
Method 
invocaYon 
Cache 
Worker 
pools 
Distributed 
2nd 
level 
cache 
Query 
Cache
Designed for high performance (?)
Then vs Now 
1970’s 
2014
Brought to us by the Financial Sector 
Sources 
(ltr 
*b): 
guides.wikinut.com 
(2x), 
telegraph.co.uk, 
commons.wikimedia.org, 
usatoday.com
Brought to us by the Financial Sector 
CQRS 
(LMAX) 
Disruptor 
mechaniYs.blogspot.com 
Source:
CQRS Based Architecture
CQRS Based Architecture 
Command 
model 
ProjecYons
CQRS Based Architecture 
Command 
model 
ProjecYons
CQRS Based Architecture 
Command 
model 
ProjecYons 
T: 
1 
mln 
/ 
s 
Resp: 
< 
10 
ms 
T: 
Thr. 
20 
/ 
s 
Resp: 
< 
100 
ms 
T: 
10 
mln 
/ 
s 
Resp. 
< 
100 
ms 
T: 
1 
/ 
s 
Resp. 
< 
10 
ms
Synchronizing models 
Command 
model 
ProjecYons 
StoredE vperonctse 
dures
CQRS Based Architecture
The power of ubiquitous events 
Polling 
ReacYve 
Cache 
evicYon 
Push 
Real-­‐Yme 
Event 
Sourcing 
LocaYon 
transparency 
Systems 
integraYon
Event Sourcing
Event Sourcing 
OrderItems 
ID 
OrderID 
Product 
Count 
1 
1 
Deluxe 
Chair 
1 
2 
1 
... 
... 
vs 
Orders 
ID 
Status 
1 
Return 
shipment 
rcvd 
Seq# 
Event 
0 
OrderCreatedEvent 
1 
ItemAddedEvent 
(2x 
Deluxe 
Chair 
-­‐ 
€ 
399) 
2 
ItemRemovedEvent 
(1x 
Deluxe 
Chair 
-­‐ 
€ 
399) 
3 
OrderConfirmed 
4 
OrderCancelledByUserEvent 
5 
ReturnShipmentReceived
Event Sourcing 
! Pros 
! Audit trail 
! Reconstruct query model(s) 
! Management reports since day 1 
! Data analysis 
! Cons 
! Maintain history (upcasters) 
! Ever-growing
Axon Framework 
! “CQRS Framework” for Java 
! Open source under Apache 2 License 
! Simplify CQRS based applications 
! Provides building blocks for CQRS applications 
! Current version*: 2.1 
! More information: www.AxonFramework.org 
* 
On 
January 
9th, 
2014
CQRS Based Architecture
Axon – Command Bus API 
commandBus.dispatch(commandMessage, 
new 
VoidCallback() 
{ 
@Override 
public 
void 
onSuccess() 
{ 
... 
} 
@Override 
public 
void 
onFailure(Throwable 
cause) 
{ 
... 
} 
}); 
@CommandHandler 
public 
void 
handle(CreateToDoItemCommand 
command) 
{ 
// 
handle 
command 
}
Axon – Event Bus API 
eventBus.publish(asEventMessage(new 
ToDoItemCompletedEvent(“todo1”))); 
@EventHandler 
public 
void 
onEvent(ToDoItemCompletedEvent 
event) 
{ 
// 
handle 
event 
}
CQRS Based Architecture 
interface 
AggregateRoot 
abstract 
class 
AbstractAggregateRoot 
interface 
EventSourcedAggregateRoot 
abstract 
class 
AbstractAnnotatedAggregateRoot
Axon – Event Sourcing 
Apply 
state 
Make 
decisions
Event Sourcing - Testing 
! Given-when-then fixtures 
! Given some past events 
! When I apply a new Command 
! Expect these new Events 
fixture.given(new GameStartedEvent(…), 
new CallMadeEvent(…), 
new TurnChangedEvent(…)) 
.when(new MakeCallCommand(…)) 
.expectEvents(new CallMadeEvent(…), 
new TurnChangedEvent(…));
Separate infrastructure from business logic 
A 
D 
B 
E 
C
Separate infrastructure from business logic 
A 
D 
B 
E 
C
Separate infrastructure from business logic 
A 
D 
B 
E 
C
Spring configuration - Simple
Spring configuration – High performance
Spring configuration – Distributed Events
Spring configuration – Distributed Commands
Infrastructure components in Axon 
! Single VM 
! SimpleCommandBus 
! SimpleEventBus 
! High Performance 
! DisruptorCommandBus 
! ... 
! Distributed 
! DistributedCommandBus + JGroupsConnector 
! ClusteringEventBus + AMQP Terminal 
! ...
Axon Roadmap 
! More distributed implementations 
! Improved OSGi support 
! DSL for definition of Command & Events 
! IDE Plugins 
! High performance Event Store
Axon Framework – Some cases 
! Finance 
! Process automation in a top 50 bank 
! Trading engine for ETF (index trackers) trading 
! Pension fund calculations at a large bank 
! On-line payment processing 
! Gaming 
! On-line bridge platform (bridgebig.com) 
! On-line casino (casumo.com) 
! Healthcare 
! Electronic Medical Record for the Geriatric Healthcare 
! Tracking and Tracing of equipment for dental implants 
! Aviation 
! Optimizing aircraft movement at a large European airport
The next time…
More information: axonframework.org 
Allard Buijze 
abu@trifork.com
Watch the video with slide synchronization on 
InfoQ.com! 
http://www.infoq.com/presentations/cqrs-axon

Mais conteúdo relacionado

Mais de C4Media

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoC4Media
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileC4Media
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020C4Media
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsC4Media
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No KeeperC4Media
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like OwnersC4Media
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaC4Media
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 

Mais de C4Media (20)

Streaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live VideoStreaming a Million Likes/Second: Real-Time Interactions on Live Video
Streaming a Million Likes/Second: Real-Time Interactions on Live Video
 
Next Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy MobileNext Generation Client APIs in Envoy Mobile
Next Generation Client APIs in Envoy Mobile
 
Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020Software Teams and Teamwork Trends Report Q1 2020
Software Teams and Teamwork Trends Report Q1 2020
 
Understand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java ApplicationsUnderstand the Trade-offs Using Compilers for Java Applications
Understand the Trade-offs Using Compilers for Java Applications
 
Kafka Needs No Keeper
Kafka Needs No KeeperKafka Needs No Keeper
Kafka Needs No Keeper
 
High Performing Teams Act Like Owners
High Performing Teams Act Like OwnersHigh Performing Teams Act Like Owners
High Performing Teams Act Like Owners
 
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 

Último

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Finance's Forgotten Treasure: an Introduction to CQRS & Axon

  • 1. An introduction to CQRS and Axon Framework Finance’s ‘forgotten’ treasure Allard Buijze – allard.buijze@trifork.nl
  • 2. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /cqrs-axon InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month
  • 3. Presented at QCon London www.qconlondon.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 4. Allard Buijze ! Software Architect at Trifork Amsterdam ! ~ 15 years of web development experience ! Strong believer in DDD and CQRS ! Developer and initiator of Axon Framework ! Java Framework for scalability and performance ! www.axonframework.org
  • 6. Evolution of a Domain Model
  • 7. Evolution of a Domain Model
  • 8. Evolution of a Domain Model
  • 9. Evolution of complexity Source: h*p://royal.pingdom.com/2008/01/09/the-­‐worst-­‐cable-­‐mess-­‐ever/
  • 10. Evolution of complexity private static final String PLAYER_COCKPIT_WATERFALL_ITEMS_QUERY = "(" + "select id, " + EntityType.NEWS_ITEM.ordinal() + " as entity_type, publish_date as sort_date " + "from news_item " + "where active = true and (" + NEWS_ITEM SELECT "poster_player_id = :playerId " + "or poster_player_id in (" + or "select destination_project friend_id from in friendship (… where origin_friend_id = :playerId " + ") " + "or project_id in (" + "select distinct project_id " + or "from donation project " + in (… "where donor_participant_id = :playerId and status = 'OK'" + ")" + "or project_id in (" + "select project_id from ambassador_project where player_id = :playerId " + "))" + UNION ALL DONATION status = ‘OK’ status = ‘OK’ ") union all (" + "select id, " + EntityType.DONATION.ordinal() + " as entity_type, approval_date as sort_date " + "from donation " + "where status = 'OK' and (" + "donor_participant_id = :playerId " + "or donor_participant_id in (" + "select destination_friend_id from friendship where origin_friend_id = :playerId" + ")" + "or raised_via_player_id = :playerId " + "or raised_via_player_id in (" + "select destination_friend_id from friendship where origin_friend_id = :playerId" + ") " + ") " + or raised_via_player in (… UNION ALL FRIENDSHIP ") union all ( " + "select id, " + EntityType.FRIENDSHIP.ordinal() + " as entity_type, created as sort_date " + "from friendship " + "where origin_friend_id = :playerId or (origin_friend_id in ( " + "select destination_friend_id from friendship where origin_friend_id = :playerId " + ") and destination_friend_id <> :playerId)" + ") ";
  • 11. Layered architecture Web Cache Session replicaYon Method invocaYon Cache Worker pools Distributed 2nd level cache Query Cache
  • 12. Designed for high performance (?)
  • 13. Then vs Now 1970’s 2014
  • 14. Brought to us by the Financial Sector Sources (ltr *b): guides.wikinut.com (2x), telegraph.co.uk, commons.wikimedia.org, usatoday.com
  • 15. Brought to us by the Financial Sector CQRS (LMAX) Disruptor mechaniYs.blogspot.com Source:
  • 17. CQRS Based Architecture Command model ProjecYons
  • 18. CQRS Based Architecture Command model ProjecYons
  • 19. CQRS Based Architecture Command model ProjecYons T: 1 mln / s Resp: < 10 ms T: Thr. 20 / s Resp: < 100 ms T: 10 mln / s Resp. < 100 ms T: 1 / s Resp. < 10 ms
  • 20. Synchronizing models Command model ProjecYons StoredE vperonctse dures
  • 22. The power of ubiquitous events Polling ReacYve Cache evicYon Push Real-­‐Yme Event Sourcing LocaYon transparency Systems integraYon
  • 24. Event Sourcing OrderItems ID OrderID Product Count 1 1 Deluxe Chair 1 2 1 ... ... vs Orders ID Status 1 Return shipment rcvd Seq# Event 0 OrderCreatedEvent 1 ItemAddedEvent (2x Deluxe Chair -­‐ € 399) 2 ItemRemovedEvent (1x Deluxe Chair -­‐ € 399) 3 OrderConfirmed 4 OrderCancelledByUserEvent 5 ReturnShipmentReceived
  • 25. Event Sourcing ! Pros ! Audit trail ! Reconstruct query model(s) ! Management reports since day 1 ! Data analysis ! Cons ! Maintain history (upcasters) ! Ever-growing
  • 26. Axon Framework ! “CQRS Framework” for Java ! Open source under Apache 2 License ! Simplify CQRS based applications ! Provides building blocks for CQRS applications ! Current version*: 2.1 ! More information: www.AxonFramework.org * On January 9th, 2014
  • 28. Axon – Command Bus API commandBus.dispatch(commandMessage, new VoidCallback() { @Override public void onSuccess() { ... } @Override public void onFailure(Throwable cause) { ... } }); @CommandHandler public void handle(CreateToDoItemCommand command) { // handle command }
  • 29. Axon – Event Bus API eventBus.publish(asEventMessage(new ToDoItemCompletedEvent(“todo1”))); @EventHandler public void onEvent(ToDoItemCompletedEvent event) { // handle event }
  • 30. CQRS Based Architecture interface AggregateRoot abstract class AbstractAggregateRoot interface EventSourcedAggregateRoot abstract class AbstractAnnotatedAggregateRoot
  • 31. Axon – Event Sourcing Apply state Make decisions
  • 32. Event Sourcing - Testing ! Given-when-then fixtures ! Given some past events ! When I apply a new Command ! Expect these new Events fixture.given(new GameStartedEvent(…), new CallMadeEvent(…), new TurnChangedEvent(…)) .when(new MakeCallCommand(…)) .expectEvents(new CallMadeEvent(…), new TurnChangedEvent(…));
  • 33. Separate infrastructure from business logic A D B E C
  • 34. Separate infrastructure from business logic A D B E C
  • 35. Separate infrastructure from business logic A D B E C
  • 37. Spring configuration – High performance
  • 38. Spring configuration – Distributed Events
  • 39. Spring configuration – Distributed Commands
  • 40. Infrastructure components in Axon ! Single VM ! SimpleCommandBus ! SimpleEventBus ! High Performance ! DisruptorCommandBus ! ... ! Distributed ! DistributedCommandBus + JGroupsConnector ! ClusteringEventBus + AMQP Terminal ! ...
  • 41. Axon Roadmap ! More distributed implementations ! Improved OSGi support ! DSL for definition of Command & Events ! IDE Plugins ! High performance Event Store
  • 42. Axon Framework – Some cases ! Finance ! Process automation in a top 50 bank ! Trading engine for ETF (index trackers) trading ! Pension fund calculations at a large bank ! On-line payment processing ! Gaming ! On-line bridge platform (bridgebig.com) ! On-line casino (casumo.com) ! Healthcare ! Electronic Medical Record for the Geriatric Healthcare ! Tracking and Tracing of equipment for dental implants ! Aviation ! Optimizing aircraft movement at a large European airport
  • 44. More information: axonframework.org Allard Buijze abu@trifork.com
  • 45.
  • 46. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/cqrs-axon