Introduction to the Micro-Company Project
The Micro-Company project serves as a comprehensive demonstration of best practices for developing a cloud-native, event-driven microservice architecture using Spring Cloud and Axon. The project is structured to showcase the capabilities and benefits of these technologies in creating scalable and efficient microservice solutions.
What is Cloud Native?
Before delving into cloud-native applications, it's essential to understand what "cloud" signifies in this context. It refers to Platform as a Service (PaaS), where infrastructure details are abstracted away from developers. A cloud-native application is designed to run in such an environment, emphasizing scalability and flexibility.
Architecture Overview
The microservice architecture splits a large application into small, independent services. Each of these services runs in its own process and communicates through lightweight methods, often using HTTP APIs or events. This architectural style supports faster innovation and adaptability, though it introduces challenges such as managing distributed data.
Key Patterns and Techniques
- Microservices: Small, autonomous services that work together.
- Command and Query Responsibility Separation (CQRS): Separating the logic for handling commands and queries.
- Event Sourcing: Storing state changes as a sequence of events.
- Domain-Driven Design (DDD) Aggregates: Grouping objects that are treated as a single unit.
Technologies Used
- Spring Boot & Spring Cloud: Frameworks for building and deploying applications.
- Axon Framework: A framework for CQRS and event sourcing.
- RabbitMQ: A message broker for event-driven communication.
- Docker: A platform for containerization of applications.
Key Benefits
- Simplifies handling of complex business transactions across services.
- Automates event publication for data changes.
- Enhances query speed and scalability through materialized views.
- Provides reliable auditing for updates.
How It Works
The project is divided into two main microservices: the command-side and the query-side.
- Command-Side: Processes commands and generates events. These events are recorded and communicated via RabbitMQ.
- Query-Side: Listens to events and builds materialized views. This side can be replicated for scalability, ensuring durability and reliability.
Services in Detail
Backing Services
These include essential services necessary for cloud-native applications, like:
- Service Registry (Netflix Eureka): Manages service instance registration and discovery.
- Authorization Server (OAuth2): Issues tokens and authorizes requests.
- Configuration Server: Centralizes configuration management.
- API Gateway: A single entry point for client requests, routing them to appropriate services.
Backend Microservices
These include:
- BlogMicroservice: Manages and queries company blog posts.
- ProjectMicroservice: Manages and queries company projects.
Running the Application
Prerequisites
Ensure you have Java JDK 8, Git, Docker, and VirtualBox installed.
Steps to Run
- Clone the Project: Download the project repository via Git.
- Build the Project: Optional, build using Maven.
- Run: Choose between running as a monolithic application or as microservices through various configurations (Docker, AWS, PCF).
For detailed commands and configurations, refer to the project's specific setup documentation.
About AXON Framework
Axon Framework structures the communication within microservices using commands, events, and queries. It supports:
- Commands: Intent messages to change system state.
- Events: Notifications of state changes, which are durable and can rebuild application state as needed.
Conclusion
The Micro-Company project showcases a modern approach to developing distributed applications, leveraging leading technologies for enhanced scalability, reliability, and performance. It serves as a valuable resource for understanding and implementing a cloud-native, event-driven microservice architecture.