Ideally, you will use the stub that's generated by the server or use the same service .proto file to generate one in the client for calling the stub from the client code. However, we'll add grpc-server-service as a dependency in the pom.xml file of grpc-client-service. This is shown in the following example:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>grpc-server-service</artifactId>
<version>${project.version}</version>
</dependency>
That's how we can simply write the method that will call the server and get the response. The io.grpc.ManagedChannelBuilder class is used for creating the channel (io.grpc.ManagedChannel) to the server. This channel is then passed to the auto generated EmployeeService stub (EmployeeServiceGrpc.EmployeeServiceBlockingStub)...