The Ping-Pong Project is a Spring Boot-based application designed to demonstrate the implementation of distributed systems using microservices architecture. The project comprises two independently deployable microservices that work in tandem to simulate a back-and-forth communication pattern.
-
Ping Service
This microservice is responsible for initiating the "Ping" action. It accepts HTTP requests from clients and sends calls to the Pong Service, receiving and processing the responses. -
Pong Service
The Pong Service complements the Ping Service by handling incoming requests from it and responding with an appropriate message. This demonstrates seamless inter-service communication within the system.
Each microservice is modular, allowing for independent scalability, testing, and deployment. This separation of concerns showcases the benefits of the microservices architecture in terms of resilience, modular development, and ease of future extension.
The following technologies are used in this project:
- Java 21: Latest features and enhancements of Java for high performance and reliability.
- Spring Boot: Provides the foundation for microservices development, offering simplicity in building and deploying services.
- Spring Web: Enables the development of RESTful APIs for inter-service and client communication.
- Lombok: Reduces boilerplate code, allowing concise and readable code for models and services.
- Spring Boot DevTools: Facilitates agile development through hot-reloading and other developer-friendly features.
-
Pre-requisites:
Ensure you have the following installed:- JDK 21
- Apache Maven (for dependency management and application building)
-
Building and Running Each Service:
Each service operates independently:- Navigate to the respective service's directory:
pingorpong. - Run the following command:
mvn spring-boot:run
You can also run with specific profiles if implemented:
mvn spring-boot:run -Dspring-boot.run.arguments="--spring.profiles.active=<profile>" - Navigate to the respective service's directory:
-
Endpoints:
- Ping Service: Initiates the interaction (e.g.,
http://localhost:8080/ping). - Pong Service: Responds to the ping request (e.g.,
http://localhost:8081/pong).
- Ping Service: Initiates the interaction (e.g.,
- Microservices Architecture: Demonstrates how to build distributed systems with fine-grained services for specific functionality.
- RESTful API Communication: Follows REST standards to ensure simplicity and compatibility.
- Independent Deployment: Each service operates independently, showcasing flexibility for scaling and maintenance.
For further reference, please consider the following sections:
- Official Apache Maven documentation
- Spring Boot Maven Plugin Reference Guide
- Create an OCI image
- Spring Web
- Spring Boot DevTools
- Validation
The following guides illustrate how to use some features concretely:
- Building a RESTful Web Service
- Serving Web Content with Spring MVC
- Building REST services with Spring
- Validation
Due to Maven's design, elements are inherited from the parent POM to the project POM. While most of the inheritance is fine, it also inherits unwanted elements like <license> and <developers> from the parent. To prevent this, the project POM contains empty overrides for these elements.
If you manually switch to a different parent and actually want the inheritance, you need to remove those overrides.
Enjoy developing and testing the Ping-Pong Project!