This educational project's main objective is to understand how gRPC works in conjunction with Spring Boot. We developed a simple calculator example, focusing on core functionality, and chose to use the latest versions of dependencies to ensure compatibility and explore the latest features available.
Throughout the development process, we pay special attention to error handling to increase the robustness of the system. We explore effective strategies for dealing with unexpected situations, ensuring a more reliable user experience. Furthermore, we highlight that gRPC was implemented in Go Lang, emphasizing the performance and efficiency of this language in building distributed services.
By implementing detailed log tracking across applications, we provide a clearer, more granular view of the execution flow. The integration of gRPC with Spring Boot in Go Lang was carried out comprehensively, highlighting not only the effectiveness of gRPC, but also the conscious choice of the Go language for this purpose.
By sharing this knowledge, we hope to provide valuable insights into best practices in integrating gRPC with Spring Boot, especially when implemented in Go Lang. This approach aims to help developers looking to improve their distributed communication skills, highlighting the efficiency and flexibility provided by this specific combination of technologies.
Keywords: gRPC, Gateway, Gateway-Api, Spring Boot 3, Java 21, Micrometer, Tracer, RESTFul, Microservices, Docker, Docker Compose.
- Install Java 21
- Install Maven 3.6.3
- Go Lang 1.23.3
- Install Docker
- Install Docker Compose
- Makefile
-
install dependencies
mvn clean install
-
grpc-server
cd grpc-server mvn spring-boot:run -
grpc-client
cd grpc-client mvn spring-boot:run -
start with docker (Optional)
- Need to create an external network.
make create-network
- Start container
make container-start
-
grpc-client
-
grpc-server
- actuator
- Check out the list of current gRPC tools at awesome-grpc
-
Reference
- What is gRPC guide
NOTE: The grpc-server server needs to be running with docker container
-
container-grpc-server
make container-grpc-server
-
generate-pb
make generate-pb
-
go-mod-tidy
make go-mod-tidy
-
container-grpc-gateway
make container-grpc-gateway
-
Example curl:
curl --location 'http://0.0.0.0:8085/v1/calculator/add' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --data '{ "num1": 1, "num2": 5 }'
NOTE: Status code 200 with response body:
{ "result": 6 } -
Reference
- What is gRPC Gateway guide

