java-design-patterns icon indicating copy to clipboard operation
java-design-patterns copied to clipboard

Microservices pattern : Self-Registration

Open naman-sriv opened this issue 10 months ago • 2 comments

Pull Request Template

What does this PR do?

Implemented the Microservices Self-Registration pattern using Spring Boot (3.4.4) and Eureka. This PR includes the Eureka Server setup and two microservices (Greeting and Context) that register with Eureka and communicate using OpenFeign. Key Spring Cloud dependencies include Eureka Discovery Client, Eureka Server, and OpenFeign.

naman-sriv avatar Apr 07 '25 07:04 naman-sriv

PR Summary

This PR implements a microservices self-registration pattern using Spring Boot, Eureka, and OpenFeign. It includes a Eureka server and two microservices (Greeting and Context) that register with Eureka and communicate with each other. The project also includes unit tests and health checks.

Changes

File Summary
microservices-self-registration/README.md This file provides a comprehensive guide to the microservices self-registration pattern implemented in the project, including its intent, structure, usage instructions, advantages, and trade-offs. It also includes references to relevant documentation.
microservices-self-registration/application.log.2025-04-09.0.gz New file.
microservices-self-registration/contextservice/.gitattributes New file.
microservices-self-registration/contextservice/.gitignore New file.
microservices-self-registration/contextservice/application.log.2025-04-05.0.gz New file.
microservices-self-registration/contextservice/application.log.2025-04-07.0.gz New file.
microservices-self-registration/contextservice/application.log.2025-04-09.0.gz New file.
microservices-self-registration/contextservice/pom.xml This file defines the project dependencies for the contextservice microservice, including Spring Boot, Spring Cloud, Eureka, OpenFeign, and testing libraries.
microservices-self-registration/contextservice/src/main/java/com/learning/contextservice/ContextserviceApplication.java This is the main application class for the contextservice microservice. It uses annotations to enable service discovery and OpenFeign client functionality.
microservices-self-registration/contextservice/src/main/java/com/learning/contextservice/MyCustomHealthCheck.java This class implements a custom health check for the contextservice that runs every 5 seconds and logs the health status.
microservices-self-registration/contextservice/src/main/java/com/learning/contextservice/client/GreetingServiceClient.java This interface defines a Feign client for communication with the greetingservice using OpenFeign.
microservices-self-registration/contextservice/src/main/java/com/learning/contextservice/controller/ContextController.java This controller handles requests to the /context endpoint, which retrieves a greeting from the greetingservice and adds contextual information.
microservices-self-registration/contextservice/src/main/resources/application.yml This file contains the configuration for the contextservice microservice, including server port, Eureka server URL, and user region.
microservices-self-registration/contextservice/src/test/java/com/learning/contextservice/ContextControllerTest.java This class contains unit tests for the ContextController, verifying its functionality and integration with the GreetingServiceClient.
microservices-self-registration/contextservice/src/test/java/com/learning/contextservice/ContextserviceApplicationTests.java This class contains a basic integration test to verify that the Spring context loads correctly for the contextservice.
microservices-self-registration/contextservice/src/test/java/com/learning/contextservice/TestConfig.java This class provides a configuration for unit testing, including a mock implementation of the GreetingServiceClient.
microservices-self-registration/contextservice/src/test/java/com/learning/contextservice/myCustomHealthCheckTest.java This class contains unit tests for the custom health check, verifying its functionality in both healthy and unhealthy states.
microservices-self-registration/eurekaserver/.gitattributes New file.
microservices-self-registration/eurekaserver/.gitignore New file.
microservices-self-registration/eurekaserver/pom.xml This file defines the project dependencies for the Eureka server, including Spring Boot and Spring Cloud.
microservices-self-registration/eurekaserver/src/main/java/com/learning/eurekaserver/EurekaserverApplication.java This is the main application class for the Eureka server. It uses annotations to enable Eureka server functionality.
microservices-self-registration/eurekaserver/src/main/resources/application.yml This file contains the configuration for the Eureka server, including server port and self-preservation settings.
microservices-self-registration/eurekaserver/src/test/java/com/learning/eurekaserver/EurekaserverApplicationTests.java This class contains a basic integration test to verify that the Spring context loads correctly for the Eureka server.
microservices-self-registration/greetingservice/.gitattributes New file.
microservices-self-registration/greetingservice/.gitignore New file.
microservices-self-registration/greetingservice/application.log.2025-04-05.0.gz New file.
microservices-self-registration/greetingservice/application.log.2025-04-07.0.gz New file.
microservices-self-registration/greetingservice/application.log.2025-04-09.0.gz New file.
microservices-self-registration/greetingservice/application.log.2025-04-11.0.gz New file.
microservices-self-registration/greetingservice/pom.xml This file defines the project dependencies for the greetingservice microservice, including Spring Boot, Spring Cloud, and Eureka.

autogenerated by presubmit.ai

github-actions[bot] avatar Apr 07 '25 07:04 github-actions[bot]

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
8.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

sonarqubecloud[bot] avatar Apr 11 '25 18:04 sonarqubecloud[bot]

This PR is stale because it has been open 60 days with no activity.

github-actions[bot] avatar Jun 12 '25 02:06 github-actions[bot]