App to demonstrate CQRS & ES based on Spring Boot and Axon
CQRS stands for Command Query Responsibility Segregation is a design pattern that aims to separate the Read and Write operations.
- Queries: a Read only operation - no state is updated after executing queries
- Commands: a Writing operation - state is updated after executing commands
Event Sourcing aims to persist the state of a business entity as a sequence of state-changing events. Every action performed on a business entity should be persisted. The application reconstructs an entity’s current state by replaying the events
We will use Axon Server to be our Event store and our dedicated command, event and query routing solution.
As an Event Store, it gives us the ideal characteristics required when storing events.
As a Message Routing solution, it gives us the option to connect several instances together without focusing on configuring things like a RabbitMQ or a Kafka topic to share and dispatch messages.
axon server jar download
A GiftCard app where a user can issue card, redeem card, reload card and cancel card.
POST /api/gift_cards
POST /api/gift_cards/cancel/{id}
PUT /api/gift_cards/redeem/{id}
PUT /api/gift_cards/reload/{id}
GET /api/gift_cards
GET /api/gift_cards/{id}
GET /api/gift_cards/{id}/events
The following guides illustrate how to run this repo locally :
git clone https://github.com/MdShohanurRahman/gift-card-app.git
add database credentials in application.properties
download axon server jar download.
unzip and goto this folder and run command java -jar axonserver.jar
run gift-card-app project with this command mvn spring-boot:run
or run by your idea.Finally, you are ready to go.
hit this url http://localhost:8081/swagger-ui/
and explore giftCard apis
For further reference, please consider the following sections: