SlideShare une entreprise Scribd logo
1  sur  73
OUR WAY TO MICROSERVICES
Supported By:
DDD – CQRS - ES
Supported By:
I’M ANDI PANGERAN
@andi_pangeran
cybercoding.wordpress.com
Supported By:
Not that way…
Supported By:
What we need right now is..
Supported By:
Refactoring our logic
Supported By:
AGENDA
 DOMAIN DRIVEN DESIGN
 COMMAND QUERY RESPONSIBILITY SEGREGATION
 EVENT SOURCING
 AMQP MESSAGING
 PROFT OF CONCEPT, SPRING BOOT + AXON FRAMEWORK
Supported By:
DOMAIN DRIVEN DESIGN
Supported By:
Introduction
Supported By:
DOMAIN DRIVEN DESIGN
• .. For most software projects, the
primary focus should be on the
domain and domain logic.
Supported By:
DOMAIN DRIVEN DESIGN
Supported By:
DOMAIN DRIVEN DESIGN
DESIGN
STRATEGIC DESIGN
TACTICAL DESIGN
Supported By:
DOMAIN DRIVEN DESIGN
DESIGN
STRATEGIC DESIGN
 Bounded Context
 Ubiquitouse Language
 Context Map
Supported By:
DOMAIN DRIVEN DESIGN
Bounded Context
General
Ledger
Account
Payable
Account
Recieveable
Assets
Management
InventoryBudget
Control
Accounting Application
Supported By:
DOMAIN DRIVEN DESIGN
Ubiquitous Language
DOMAIN EXPERT
Developer
Supported By:
DOMAIN DRIVEN DESIGN
Context Map
Context mapping is a design process where the contact points and translations
between bounded contexts are explicitly mapped out. Focus on mapping the existing
landscape, and deal with the actual transformations later.
?Relation
General Ledger
Account Payable
Supported By:
DOMAIN DRIVEN DESIGN
Shared Kernel
Supported By:
DOMAIN DRIVEN DESIGN
Relation Pattern
 Open House Services
 Customer – Supplier
 Anti Corruption Layer
Supported By:
DOMAIN DRIVEN DESIGN
Strategic Design
Supported By:
DOMAIN DRIVEN DESIGN
DESIGN
 Entity
 Value Object
 Aggregates
 Domain Events
 Layered Architecture
TACTICAL DESIGN
Supported By:
Entity & Value Object
Entity…
An object fundamentally defined not by its attributes, but by
a thread of continuity and identity.
Value Object…
An immutable object that describes some characteristic or
attribute but carries no concept of identity.
Supported By:
Aggregate
…
Cluster of associated objects that are treated as a unit for
the purpose of data changes.
…
Aggregate enforce concictency
Order Line Items
Customer
Shipping
Address
Aggregate Root
Supported By:
Domain Events
…
Something meaningful that happened in the Domain
…
Communicating state changes of Aggregates
…
Immutable Value Objects
Supported By:
Layered Architecture
Domain
Application
Infrastructure
Entity
Value Object
Repository
Supported By:
DOMAIN DRIVEN DESIGN
Tactical Design
Refactoring ?
Supported By:
CQRS
Supported By:
Introduction
Supported By:
CQRS
Pioneered by Greg Young & Udi Dahan
In this context,
» Commands = Writes
» Queries = Reads
Command/Query Responsibility Segregation (CQRS) is the idea
that you can use a different model to update information than
the model you use to read information.
Supported By:
CQRS
Supported By:
Why Is CQRS needed ?
Read vs Write Capacity…
Scale read operations differently from write operations
Split the concerns…
Simplicity in domain model by separating read and writes.
Decreased COMPLEXITY…
Write need validation and consequential logic.
Read have many representation model, and storage mechanism
(polyglot storage)
Supported By:
How Does CQRS work ?
Persistent View Model schema
matches UI view model
Scale out
as many
copies as
needed
Command captures the
intent of the user
Commandbus deliver
command to command
handler
A queue can be
utilized to optimize
write performance
After database is
updated, publish result
to view model via
eventbus
Supported By:
How Does CQRS work ?
Command
 Commands encapsulate the user’s intent
but do not contain business logic, only
enough data for the command.
 Command message handled by
command handler.
 Just once command handler / command
message.
 Command handler can reject a
command, validation / bussines rules
violation
Supported By:
How Does CQRS work ?
Event
 Events describe changes in the system
state.
 An Event Bus can be utilized to dispatch
events to subscribers.
 Events primary purpose update the read
model
 Events can also provider integration with
external systems
 CQRS can also be used in conjunction
with Event Sourcing.
Event Sourcing
Supported By:
Introduction
Supported By:
Traditional systems store current state
INSERT INTO charging_stations
VALUES (“CP001”, “Acme Corp.”, “Widget B”);
INSERT INTO charging_stations
VALUES (“CP003”, “ABC Widgets”, “Model-1”);
UPDATE charging_stations
SET model = “Widget A”
WHERE identity = “CP001”;
Supported By:
Traditional systems store current state
Supported By:
Traditional systems store current state
keeping only the current state…
lot of valuable historic data is lost, e.g. the information about the
time a state change happened, who invoked the change, and so
on. This historic data may remind you of something called an
audit log.
conceptual model…
there is no single model that could be used universally for every
possible case that the system needs to address. Moreover, the
structure of the application data tends to change overtime..
Supported By:
Store the sequence of events that led up to the current state.
Supported By:
populate the application state via projection
Supported By:
Snapshoting
SNAPSHOT
CQRS
Supported By:
Back to
Supported By:
How Does CQRS work ?
Persistent View Model
 Read model can be denormalized
RDBMS, document store, etc.
 Optimize read model with different data
storage technologies for different kinds
of data (polyglot)
 Eventually Concistence
Supported By:
How do we apply the Concepts ?
Supported By:
CORE
Supported By:
CORE
Supported By:
CORE
Supported By:
CTM CORE
Supported By:
CORE
Supported By:
CTM CORE
Supported By:
CORE
Advanced Message Queuing Protocol (AMQP)
Supported By:
Introduction
Supported By:
AMQP IN A NUTSHELL
A producer is a user
application that
sends messages
A exchange is message router
that routes message to
queue. There is Direct,
Fanout, Topic Exchange
A queue is a buffer that
stores messages
A consumer
is a user
application
that receives
messages.
Supported By:
Fanout Exchange
A fanout exchange routes messages to all of the queues that are bound to it and the routing
key is ignored. If N queues are bound to a fanout exchange, when a new message is
published to that exchange a copy of the message is delivered to all N queues. Fanout
exchanges are ideal for the broadcast routing of messages.
Supported By:
Direct Exchange
A direct exchange delivers messages to queues based on the message routing key
Supported By:
Topic Exchange
Topic exchanges route messages to one or many queues based on matching between a
message routing key and the pattern that was used to bind a queue to an exchange.
Supported By:
Sample Spring AMQP Configuration
Axon Framework
Supported By:
Introduction
Supported By:
Why Axon Framework
Compatibility with CQRS and ES …
Axon Framework is a Java Framework for scalable and high performance applications and being
focused on making life easier for developers that want to create applications based on the CQRS
principles and concepts, i.e. commands, events, aggregates, entities, sagas, etc. On top of that, it
also supports event sourcing.
Integrability…
It supports the Spring Framework's configuration and dependency injection. It also uses Java
annotations for building the domain model and event listeners without being tied to the Axon's
specific logic.
Active development and support…
the latest version at the time of writing this was 2.4.4. It is actively developed, a new major version
3 is a work in progress. It has nice and detailed documentation and a sample project to showcase
the code. The authors also provide commercial services such as support contracts, training, and
consultancy.
Popularity…
The code repository on GitHub has more than 300 stars and 100 forks. The user community is
active on the mailing lists and on the issue tracker.
Supported By:
Axon Framework
CommandBus
SimpleCommandBus…
It does straightforward processing of commands in the thread that dispatches them. After a
command is processed, the modified aggregate(s) are saved and generated events are published in
that same thread.
AsynchronousCommandBus …
It does processing of commands in new thread. After a command is processed, the modified
aggregate(s) are saved and generated events are published in that same thread.
DisruptorCommandBus …
The DisruptorCommandBus takes a different approach to multithreaded processing. Instead of
doing the processing in the calling thread, the tasks are handed off to two groups of threads, that
each take care of a part of the processing. The first group of threads will execute the command
handler, changing an aggregate's state. The second group will store and publish the events to the
Event Store and Event Bus.
Supported By:
Axon Framework
SimpleCommandbus Configuration
Supported By:
Axon Framework
AsynchronousCommandBus Configuration
Supported By:
Axon Framework
DisruptorCommandBus Configuration
Supported By:
Axon Framework
EventBus
SimpleEventBus …
The SimpleEventBus just dispatches each incoming Event to each of the subscribed EventListeners
sequentially. If an EventListener throws an Exception, dispatching stops and the exception is
propagated to the component publishing the Event..
ClusteringEventsBus …
The ClusteringEventsBus allows application developers
to bundle EventListeners into Clusters based on their
properties and non-functional requirements. The
ClusteringEventBus is also more capable to deal with
Events being dispatched among different machines.
Contains two mechanisms: the ClusterSelector, which
selects a Cluster instance for each of the registered
EventListeners, and the EventBusTerminal, which is
responsible for dispatching Events to each of the
relevant clusters..
Supported By:
Axon Framework
SimpleEventBus Configuration
Supported By:
Axon Framework
ClusteringEventBus Configuration
Supported By:
Axon Framework
Event Store
FileSystemEventStore…
The FileSystemEventStore stores the events in a file on the file system. It provides good
performance and easy configuration. Not a suitable implementation for production environments
JpaEventStore …
The JpaEventStore stores events in a JPA-compatible data source. Unlike the file system version, the
JPAEventStore supports transactions. The JPA Event Store stores events in so called entries. To use
the JpaEventStore, you must have the JPA (javax.persistence) annotations on your classpath..
JDBC Event Store …
The JDBC event store uses a JDBC Connection to store Events in a JDBC compatible data storage.
Typically, these are relational databases. Theoretically, anything that has a JDBC driver could be
used to back the JDBC Event Store.
MongoDB Event Store …
Use mongodb to store Events.
Supported By:
Axon Framework
JdbcEventStore Configuration
Supported By:
Axon Framework
MongoDb EventStore Configuration
Supported By:
Axon Framework
Aggregate Repositories
GenericJpaRepository…
This is a repository implementation that can store JPA compatible Aggregates. It is configured with
an EntityManager to manage the actual persistence, and a class specifying the actual type of
Aggregate stored in the Repository.
EventSourcingRepository …
The EventSourcingRepository implementation provides the basic functionality needed by any event
sourcing repository in the AxonFramework.
HybridJpaRepository…
The HybridJpaRepository is a combination of the GenericJpaRepository and an Event Sourcing
repository. It can only deal with event sourced aggregates, and stores them in a relational model as
well as in an event store. When the repository reads an aggregate back in, it uses the relational
model exclusively..
Supported By:
Axon Framework
Sample Repository Configuration
Spring Boot + Axon Framework
Supported By:
Proft Of Concept
QUESTIONS ?
Supported By:
Supported By:
Recommended Reading
Thanks
Supported By:

Contenu connexe

Tendances

Saa s multitenant database architecture
Saa s multitenant database architectureSaa s multitenant database architecture
Saa s multitenant database architecture
mmubashirkhan
 
Google Cloud and Confluent Streaming: Generating Real Value From Real Time | ...
Google Cloud and Confluent Streaming: Generating Real Value From Real Time | ...Google Cloud and Confluent Streaming: Generating Real Value From Real Time | ...
Google Cloud and Confluent Streaming: Generating Real Value From Real Time | ...
confluent
 

Tendances (20)

Developing microservices with aggregates (SpringOne platform, #s1p)
Developing microservices with aggregates (SpringOne platform, #s1p)Developing microservices with aggregates (SpringOne platform, #s1p)
Developing microservices with aggregates (SpringOne platform, #s1p)
 
Axon Framework, Exploring CQRS and Event Sourcing Architecture
Axon Framework, Exploring CQRS and Event Sourcing ArchitectureAxon Framework, Exploring CQRS and Event Sourcing Architecture
Axon Framework, Exploring CQRS and Event Sourcing Architecture
 
Webinar - What's new in Axon 3
Webinar - What's new in Axon 3 Webinar - What's new in Axon 3
Webinar - What's new in Axon 3
 
Going Serverless with CQRS on AWS
Going Serverless with CQRS on AWSGoing Serverless with CQRS on AWS
Going Serverless with CQRS on AWS
 
Saa s multitenant database architecture
Saa s multitenant database architectureSaa s multitenant database architecture
Saa s multitenant database architecture
 
Event Sourcing - Greg Young
Event Sourcing - Greg YoungEvent Sourcing - Greg Young
Event Sourcing - Greg Young
 
Modeling microservices using DDD
Modeling microservices using DDDModeling microservices using DDD
Modeling microservices using DDD
 
CQRS and what it means for your architecture
CQRS and what it means for your architectureCQRS and what it means for your architecture
CQRS and what it means for your architecture
 
Event Streaming CTO Roundtable for Cloud-native Kafka Architectures
Event Streaming CTO Roundtable for Cloud-native Kafka ArchitecturesEvent Streaming CTO Roundtable for Cloud-native Kafka Architectures
Event Streaming CTO Roundtable for Cloud-native Kafka Architectures
 
Command Query Responsibility Segregation (CQRS)
Command Query Responsibility Segregation (CQRS)Command Query Responsibility Segregation (CQRS)
Command Query Responsibility Segregation (CQRS)
 
Google Cloud and Confluent Streaming: Generating Real Value From Real Time | ...
Google Cloud and Confluent Streaming: Generating Real Value From Real Time | ...Google Cloud and Confluent Streaming: Generating Real Value From Real Time | ...
Google Cloud and Confluent Streaming: Generating Real Value From Real Time | ...
 
How to write your database: the story about Event Store
How to write your database: the story about Event StoreHow to write your database: the story about Event Store
How to write your database: the story about Event Store
 
20160317 lagom sf scala
20160317 lagom sf scala20160317 lagom sf scala
20160317 lagom sf scala
 
Building event-driven Microservices with Kafka Ecosystem
Building event-driven Microservices with Kafka EcosystemBuilding event-driven Microservices with Kafka Ecosystem
Building event-driven Microservices with Kafka Ecosystem
 
Bank of China (HK) Tech Talk 1: Dive Into Apache Kafka
Bank of China (HK) Tech Talk 1: Dive Into Apache KafkaBank of China (HK) Tech Talk 1: Dive Into Apache Kafka
Bank of China (HK) Tech Talk 1: Dive Into Apache Kafka
 
CQRS
CQRSCQRS
CQRS
 
Service Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications todayService Fabric – building tomorrows applications today
Service Fabric – building tomorrows applications today
 
Jay Kreps, Confluent | Kafka Summit SF 2019 Keynote ft. Dev Tagare, Lyft + Pr...
Jay Kreps, Confluent | Kafka Summit SF 2019 Keynote ft. Dev Tagare, Lyft + Pr...Jay Kreps, Confluent | Kafka Summit SF 2019 Keynote ft. Dev Tagare, Lyft + Pr...
Jay Kreps, Confluent | Kafka Summit SF 2019 Keynote ft. Dev Tagare, Lyft + Pr...
 
Microservices design patterns
Microservices design patternsMicroservices design patterns
Microservices design patterns
 
Multi-tenancy in Java
Multi-tenancy in JavaMulti-tenancy in Java
Multi-tenancy in Java
 

Similaire à Our way to microservices

Resume_Ashok-updated (1) (1)
Resume_Ashok-updated (1) (1)Resume_Ashok-updated (1) (1)
Resume_Ashok-updated (1) (1)
chimmili ashok
 
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot InstancesWorkshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Amazon Web Services
 

Similaire à Our way to microservices (20)

Day 4 - Cloud Migration - But How?
Day 4 - Cloud Migration - But How?Day 4 - Cloud Migration - But How?
Day 4 - Cloud Migration - But How?
 
Data Con LA 2022 - Event Sourcing with Apache Pulsar and Apache Quarkus
Data Con LA 2022 - Event Sourcing with Apache Pulsar and Apache QuarkusData Con LA 2022 - Event Sourcing with Apache Pulsar and Apache Quarkus
Data Con LA 2022 - Event Sourcing with Apache Pulsar and Apache Quarkus
 
Introduction to Axon FrameWork with CQRS pattern
Introduction to Axon FrameWork with CQRS patternIntroduction to Axon FrameWork with CQRS pattern
Introduction to Axon FrameWork with CQRS pattern
 
Tech-Spark: Exploring the Cosmos DB
Tech-Spark: Exploring the Cosmos DBTech-Spark: Exploring the Cosmos DB
Tech-Spark: Exploring the Cosmos DB
 
Resume_Ashok-updated (1) (1)
Resume_Ashok-updated (1) (1)Resume_Ashok-updated (1) (1)
Resume_Ashok-updated (1) (1)
 
AWS re:Invent 2016: Chalk Talk: Succeeding at Infrastructure-as-Code (GPSCT312)
AWS re:Invent 2016: Chalk Talk: Succeeding at Infrastructure-as-Code (GPSCT312)AWS re:Invent 2016: Chalk Talk: Succeeding at Infrastructure-as-Code (GPSCT312)
AWS re:Invent 2016: Chalk Talk: Succeeding at Infrastructure-as-Code (GPSCT312)
 
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdfSchema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
Schema-based multi-tenant architecture using Quarkus & Hibernate-ORM.pdf
 
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
AI&BigData Lab 2016. Сарапин Виктор: Размер имеет значение: анализ по требова...
 
Microservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native AppsMicroservices Architecture - Cloud Native Apps
Microservices Architecture - Cloud Native Apps
 
Workshop: Deploy a Deep Learning Framework on Amazon ECS
Workshop: Deploy a Deep Learning Framework on Amazon ECSWorkshop: Deploy a Deep Learning Framework on Amazon ECS
Workshop: Deploy a Deep Learning Framework on Amazon ECS
 
Sky High With Azure
Sky High With AzureSky High With Azure
Sky High With Azure
 
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
Winning the Lottery with Spring: A Microservices Case Study for the Dutch Lot...
 
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot InstancesWorkshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
Workshop; Deploy a Deep Learning Framework on Amazon ECS and Spot Instances
 
AWS Certified Solutions Architect Associate Notes.pdf
AWS Certified Solutions Architect Associate Notes.pdfAWS Certified Solutions Architect Associate Notes.pdf
AWS Certified Solutions Architect Associate Notes.pdf
 
GWAB 2015 - Data Plaraform
GWAB 2015 - Data PlaraformGWAB 2015 - Data Plaraform
GWAB 2015 - Data Plaraform
 
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
Amazon EKS 그리고 Service Mesh (김세호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
 
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...
XebiCon'17 : AxonFramework @ SGCIB (our experience) : (CQRS, Eventsourcing, A...
 
Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?
 
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot InstancesWKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
WKS401 Deploy a Deep Learning Framework on Amazon ECS and EC2 Spot Instances
 
Windows Azure - Uma Plataforma para o Desenvolvimento de Aplicações
Windows Azure - Uma Plataforma para o Desenvolvimento de AplicaçõesWindows Azure - Uma Plataforma para o Desenvolvimento de Aplicações
Windows Azure - Uma Plataforma para o Desenvolvimento de Aplicações
 

Dernier

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Dernier (20)

%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 

Our way to microservices

  • 1. OUR WAY TO MICROSERVICES Supported By: DDD – CQRS - ES
  • 2. Supported By: I’M ANDI PANGERAN @andi_pangeran cybercoding.wordpress.com
  • 5. What we need right now is.. Supported By:
  • 7. AGENDA  DOMAIN DRIVEN DESIGN  COMMAND QUERY RESPONSIBILITY SEGREGATION  EVENT SOURCING  AMQP MESSAGING  PROFT OF CONCEPT, SPRING BOOT + AXON FRAMEWORK Supported By:
  • 9. Supported By: DOMAIN DRIVEN DESIGN • .. For most software projects, the primary focus should be on the domain and domain logic.
  • 11. Supported By: DOMAIN DRIVEN DESIGN DESIGN STRATEGIC DESIGN TACTICAL DESIGN
  • 12. Supported By: DOMAIN DRIVEN DESIGN DESIGN STRATEGIC DESIGN  Bounded Context  Ubiquitouse Language  Context Map
  • 13. Supported By: DOMAIN DRIVEN DESIGN Bounded Context General Ledger Account Payable Account Recieveable Assets Management InventoryBudget Control Accounting Application
  • 14. Supported By: DOMAIN DRIVEN DESIGN Ubiquitous Language DOMAIN EXPERT Developer
  • 15. Supported By: DOMAIN DRIVEN DESIGN Context Map Context mapping is a design process where the contact points and translations between bounded contexts are explicitly mapped out. Focus on mapping the existing landscape, and deal with the actual transformations later. ?Relation General Ledger Account Payable
  • 16. Supported By: DOMAIN DRIVEN DESIGN Shared Kernel
  • 17. Supported By: DOMAIN DRIVEN DESIGN Relation Pattern  Open House Services  Customer – Supplier  Anti Corruption Layer
  • 18. Supported By: DOMAIN DRIVEN DESIGN Strategic Design
  • 19. Supported By: DOMAIN DRIVEN DESIGN DESIGN  Entity  Value Object  Aggregates  Domain Events  Layered Architecture TACTICAL DESIGN
  • 20. Supported By: Entity & Value Object Entity… An object fundamentally defined not by its attributes, but by a thread of continuity and identity. Value Object… An immutable object that describes some characteristic or attribute but carries no concept of identity.
  • 21. Supported By: Aggregate … Cluster of associated objects that are treated as a unit for the purpose of data changes. … Aggregate enforce concictency Order Line Items Customer Shipping Address Aggregate Root
  • 22. Supported By: Domain Events … Something meaningful that happened in the Domain … Communicating state changes of Aggregates … Immutable Value Objects
  • 24. Supported By: DOMAIN DRIVEN DESIGN Tactical Design
  • 27. Supported By: CQRS Pioneered by Greg Young & Udi Dahan In this context, » Commands = Writes » Queries = Reads Command/Query Responsibility Segregation (CQRS) is the idea that you can use a different model to update information than the model you use to read information.
  • 29. Supported By: Why Is CQRS needed ? Read vs Write Capacity… Scale read operations differently from write operations Split the concerns… Simplicity in domain model by separating read and writes. Decreased COMPLEXITY… Write need validation and consequential logic. Read have many representation model, and storage mechanism (polyglot storage)
  • 30. Supported By: How Does CQRS work ? Persistent View Model schema matches UI view model Scale out as many copies as needed Command captures the intent of the user Commandbus deliver command to command handler A queue can be utilized to optimize write performance After database is updated, publish result to view model via eventbus
  • 31. Supported By: How Does CQRS work ? Command  Commands encapsulate the user’s intent but do not contain business logic, only enough data for the command.  Command message handled by command handler.  Just once command handler / command message.  Command handler can reject a command, validation / bussines rules violation
  • 32. Supported By: How Does CQRS work ? Event  Events describe changes in the system state.  An Event Bus can be utilized to dispatch events to subscribers.  Events primary purpose update the read model  Events can also provider integration with external systems  CQRS can also be used in conjunction with Event Sourcing.
  • 34. Supported By: Traditional systems store current state INSERT INTO charging_stations VALUES (“CP001”, “Acme Corp.”, “Widget B”); INSERT INTO charging_stations VALUES (“CP003”, “ABC Widgets”, “Model-1”); UPDATE charging_stations SET model = “Widget A” WHERE identity = “CP001”;
  • 35. Supported By: Traditional systems store current state
  • 36. Supported By: Traditional systems store current state keeping only the current state… lot of valuable historic data is lost, e.g. the information about the time a state change happened, who invoked the change, and so on. This historic data may remind you of something called an audit log. conceptual model… there is no single model that could be used universally for every possible case that the system needs to address. Moreover, the structure of the application data tends to change overtime..
  • 37. Supported By: Store the sequence of events that led up to the current state.
  • 38. Supported By: populate the application state via projection
  • 41. Supported By: How Does CQRS work ? Persistent View Model  Read model can be denormalized RDBMS, document store, etc.  Optimize read model with different data storage technologies for different kinds of data (polyglot)  Eventually Concistence
  • 42. Supported By: How do we apply the Concepts ?
  • 50. Advanced Message Queuing Protocol (AMQP) Supported By: Introduction
  • 51. Supported By: AMQP IN A NUTSHELL A producer is a user application that sends messages A exchange is message router that routes message to queue. There is Direct, Fanout, Topic Exchange A queue is a buffer that stores messages A consumer is a user application that receives messages.
  • 52. Supported By: Fanout Exchange A fanout exchange routes messages to all of the queues that are bound to it and the routing key is ignored. If N queues are bound to a fanout exchange, when a new message is published to that exchange a copy of the message is delivered to all N queues. Fanout exchanges are ideal for the broadcast routing of messages.
  • 53. Supported By: Direct Exchange A direct exchange delivers messages to queues based on the message routing key
  • 54. Supported By: Topic Exchange Topic exchanges route messages to one or many queues based on matching between a message routing key and the pattern that was used to bind a queue to an exchange.
  • 55. Supported By: Sample Spring AMQP Configuration
  • 57. Supported By: Why Axon Framework Compatibility with CQRS and ES … Axon Framework is a Java Framework for scalable and high performance applications and being focused on making life easier for developers that want to create applications based on the CQRS principles and concepts, i.e. commands, events, aggregates, entities, sagas, etc. On top of that, it also supports event sourcing. Integrability… It supports the Spring Framework's configuration and dependency injection. It also uses Java annotations for building the domain model and event listeners without being tied to the Axon's specific logic. Active development and support… the latest version at the time of writing this was 2.4.4. It is actively developed, a new major version 3 is a work in progress. It has nice and detailed documentation and a sample project to showcase the code. The authors also provide commercial services such as support contracts, training, and consultancy. Popularity… The code repository on GitHub has more than 300 stars and 100 forks. The user community is active on the mailing lists and on the issue tracker.
  • 58. Supported By: Axon Framework CommandBus SimpleCommandBus… It does straightforward processing of commands in the thread that dispatches them. After a command is processed, the modified aggregate(s) are saved and generated events are published in that same thread. AsynchronousCommandBus … It does processing of commands in new thread. After a command is processed, the modified aggregate(s) are saved and generated events are published in that same thread. DisruptorCommandBus … The DisruptorCommandBus takes a different approach to multithreaded processing. Instead of doing the processing in the calling thread, the tasks are handed off to two groups of threads, that each take care of a part of the processing. The first group of threads will execute the command handler, changing an aggregate's state. The second group will store and publish the events to the Event Store and Event Bus.
  • 62. Supported By: Axon Framework EventBus SimpleEventBus … The SimpleEventBus just dispatches each incoming Event to each of the subscribed EventListeners sequentially. If an EventListener throws an Exception, dispatching stops and the exception is propagated to the component publishing the Event.. ClusteringEventsBus … The ClusteringEventsBus allows application developers to bundle EventListeners into Clusters based on their properties and non-functional requirements. The ClusteringEventBus is also more capable to deal with Events being dispatched among different machines. Contains two mechanisms: the ClusterSelector, which selects a Cluster instance for each of the registered EventListeners, and the EventBusTerminal, which is responsible for dispatching Events to each of the relevant clusters..
  • 65. Supported By: Axon Framework Event Store FileSystemEventStore… The FileSystemEventStore stores the events in a file on the file system. It provides good performance and easy configuration. Not a suitable implementation for production environments JpaEventStore … The JpaEventStore stores events in a JPA-compatible data source. Unlike the file system version, the JPAEventStore supports transactions. The JPA Event Store stores events in so called entries. To use the JpaEventStore, you must have the JPA (javax.persistence) annotations on your classpath.. JDBC Event Store … The JDBC event store uses a JDBC Connection to store Events in a JDBC compatible data storage. Typically, these are relational databases. Theoretically, anything that has a JDBC driver could be used to back the JDBC Event Store. MongoDB Event Store … Use mongodb to store Events.
  • 67. Supported By: Axon Framework MongoDb EventStore Configuration
  • 68. Supported By: Axon Framework Aggregate Repositories GenericJpaRepository… This is a repository implementation that can store JPA compatible Aggregates. It is configured with an EntityManager to manage the actual persistence, and a class specifying the actual type of Aggregate stored in the Repository. EventSourcingRepository … The EventSourcingRepository implementation provides the basic functionality needed by any event sourcing repository in the AxonFramework. HybridJpaRepository… The HybridJpaRepository is a combination of the GenericJpaRepository and an Event Sourcing repository. It can only deal with event sourced aggregates, and stores them in a relational model as well as in an event store. When the repository reads an aggregate back in, it uses the relational model exclusively..
  • 69. Supported By: Axon Framework Sample Repository Configuration
  • 70. Spring Boot + Axon Framework Supported By: Proft Of Concept