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

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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 

Último (20)

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)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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?
 

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