Using gRPC
gRPC is an RPC framework originally invented at Google. Unlike Thrift, gRPC makes use of existing technologies, specifically protocol buffers, for its IDL and HTTP/2 for its transport layer. After having completed the previous recipe, aspects of gRPC will feel similar to aspects of Thrift. Instead of the Thrift IDL, types and services are defined in a .proto
file. The .proto
file can then be used to generate code using the protocol buffer's compiler.
How to do it...
- Create a new Gradle/Java project with the following
build.gradle
file. Of note here is that we're installing and configuring theprotobuf
Gradle plugin, which will allow us to generate code fromprotobuf
files using Gradle, and we're listing the requiredprotobuf
libraries as dependencies. Finally, we have to tell our IDE where to look for generated classes:
group 'com.packtpub.microservices' version '1.0-SNAPSHOT' buildscript { repositories { mavenCentral() } dependencies { classpath 'com...