Junior — Middle
What methods of data retrieval from microservices have you used in your last project?
sobes.tech AI
Answer from AI
In my last project, the following methods were used to obtain data from microservices:
-
REST API: The main method of interaction was HTTP requests (GET, POST, etc.) to RESTful services using JSON for data transfer.
-
Feign Client: To simplify calls to REST services, Feign was used — a declarative HTTP client that automatically constructs requests.
-
gRPC: For some high-performance services, gRPC was used — a remote procedure call protocol using protocol buffers.
-
Message Broker: In some cases, data was transmitted through message brokers (e.g., Kafka or RabbitMQ) for asynchronous interaction between microservices.
Example of calling a REST service using Feign:
@FeignClient(name = "user-service")
public interface UserClient {
@GetMapping("/users/{id}")
User getUserById(@PathVariable("id") Long id);
}