Microservices with gRPC and REST using Spring Boot

For the project, I would like to set up a small microservice script using Spring Boot with an API gateway that provides REST and GraphQL clients, an Eureka service registry, and three services. I want all services included in the API gateway to discuss gRPC for performance reasons, but at the same time still show an additional REST API. Is there an easy way to implement both types of interfaces on the same business logic? And how is the proxy server gateway of HTTP client requests on gRPC?

+6
source share
1 answer

You can take a look at LogNet grpc-spring-boot-starter to learn how to integrate gRPC into Spring Boot, it also has a section on Eureka.

According to the Eureka example, make sure that you do not create a new connection through gRPC for each call.

Depending on the implementation of the API gateway, it must also communicate with Eureka and access downstream services by logical name through gRPC.

As in the second part, just implement your business logic in Spring Services and redirect calls to them from transport-related abstractions (controllers and gRPC services).

If you wish, you can go even further and define all messages only in Protobuf. And then register Spring Protobuf Converter for HTTP.

0
source

Source: https://habr.com/ru/post/1674825/


All Articles