Implementing gRPC Using Spring Boot and Gradle


Background

GRPC (gRPC) is a RPC framework pioneered by google later on made public and open source.
GRPC has not been officially supported by Spring Framework, so far there are few community libraries that can work seamlessly with Spring Boot. In this article, I will use the lognet's grpc-spring-boot-starter.

Project Structure

Ideally, the proto files for gRPC is located in another directory, which will then be accessed by the gradle plugin to auto generate the required files.

 


Gradle Script

The heart of gRPC enablement lies on the grpc boot starter, which includes few other tasks outlined as below.
https://github.com/overtakerx/grpcbootdemo/blob/main/build.gradle
Few important note: first you have to run gradlew compileJava for the auto generation to generate the files from the proto file, then you will need to rebuild the project for Intellij to recognise the auto-generated files.

Full demo: https://github.com/overtakerx/grpcbootdemo

References:

  • gRPC: https://grpc.io/
  • lognet gRPC Boot Starter: https://github.com/LogNet/grpc-spring-boot-starter
  • GRPC + Spring Boot + Gradle Demo: https://github.com/overtakerx/grpcbootdemo

Comments

Popular posts from this blog

Spring Boot 2: Parallelism with Spring WebFlux

Spring Boot Reactive API Part 2