- CQRS enforce segregation of read and write data model.
- CQRS is derived from CQS (Command Query Separation), the term mentioned for the first time in the book by Bertrand Meyer (Object Oriented Software Construction).
- It's main idea is split application majorly in two parts:
- Query
- These are the read models that are going to fetch data, without modifying the state.
- Command
- These are the write models that modify the state.
- Query
- The domain object has to implement functions for fetching and modifying the state. Each function can either read or write but not both.
- Validate the command.
- Provide a place holder to implement logic based on which the event has to trigger.
- Asynchronously receives event.
- Persist event in Write DB
- Asynchronously receives event.
- Can publish the projected state in Read DB.
- Query projected results from Read DB.
- Spring Boot
- Axon Framework
- Kotlin
docker run -p 8024:8024 -p 8124:8124 axoniq/axonserver
- 8024: Http Port
- 8124: gRPC Port
docker run -e POSTGRES_PASSWORD=admin123 -e POSTGRES_USER=admin -p 5432:5432 postgres