This is the case study project built during the course Learn how to create microservices that are based on CQRS & Event Sourcing. Powered by Spring Boot and Apache Kafka.
Use Visual Studio code with remote containers extension - a configuration is included in this repository.
- Ensure that MongoDB, MySQL, Kafka, and Zookeeper containers are running and reachable from your machine.
- A docker compose configuration file is provided: use it!
- Run both
AccountCommandApplication
andAccountQueryApplication
- Use the sample REST invocations, like in this folder (using VSC REST Client extension).
This is only a case-study for practicing the concepts - it is not production ready in any way.
For example, publishing events is done in not transactional way (e.g., there is no Outbox pattern implemented).
You probably want to use existing libraries or frameworks for doing proper CQRS applications, see this video for ideas.
- Error handling is missing - using a central
ControllerAdvice
makes sense - Unit and integrations are missing - yep, sadly the course was not supporting automatic testing but it should not be a problem to retrofit these.
- integration tests are the most difficult since there are many moving pieces around
- unit tests should be easy to do
CQRS is a technical architecture for supporting Domain-Driven Design, so you may want to dive deep in this approach and understand its consequences. Besides google'ing and watching videos, you may want to read the following:
- Domain Driven Design - this is the historical book from Eric Evans, it is not really practical but still valuable.
- Learning Domain-Driven Design - this is a great summary, connecting the business modelling and architectural implementation with a lot of examples. It is not providing you with a ready-to-use solution but it gives you the needed high-level views for understanding how business agility and software architectures relates in the DDD context.