Junior — Middle
How was the integration process of a microservice carried out in your last project, and through what mechanism?
sobes.tech AI
Answer from AI
In my last project, microservice integration was carried out via REST API using Spring Boot. The integration mechanism included:
- Defining API contracts with OpenAPI/Swagger to agree on request and response formats.
- Using an HTTP client (e.g., RestTemplate or WebClient) to call other microservices.
- Handling errors and timeouts to ensure robustness.
- Implementing authentication and authorization mechanisms (e.g., JWT).
Example of calling another microservice via WebClient:
WebClient webClient = WebClient.create("http://other-service");
Mono<Response> response = webClient.get()
.uri("/api/data/{id}", id)
.retrieve()
.bodyToMono(Response.class);
response.subscribe(r -> System.out.println(r));
Also used orchestration and service discovery systems (e.g., Eureka) for dynamic discovery of microservice addresses.