Use Case: Internal API Calls with Manual Clients
About
This use case demonstrates how one Spring Boot service (Service 1) can invoke a GET API exposed by another internal service (Service 2) using OpenFeign, a modern HTTP client introduced in Spring 5.
Service 2
Dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>SampleController.java
package org.example.api;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SampleController {
@GetMapping("/api/service-2/details")
public ResponseEntity<String> getInterServiceDetails() {
return ResponseEntity.ok("Service 2 processed successfully");
}
}Application.java
application.yaml
Build and run the application
Service 1
Dependency
SampleController.java
Service2Client.java
SampleService.java
Main Application.java
application.yaml
Verification
Build and run the application
Run the service 1 API from Postman


Enable Feign logs
To Enable Feign logging, add the below bean and update application.yaml property file.
FeignClientConfiguration.java
application.yaml
Hit the API again via Postman and monitor the logs.

Last updated