February 2019
Intermediate to advanced
446 pages
10h 55m
English
gRPC provides the server builder (io.grpc.ServerBuilder) for building and binding the services it can allow calls to. Once server initialization is done, we can start it and wait for termination to exit the process, as shown in the following code:
public class GrpcServer { public static void main(String[] arg) { try { Server server = ServerBuilder.forPort(8080) .addService(new EmployeeService()) .build(); System.out.println("Starting gRPC Server Service ..."); server.start(); System.out.println("Server has started at port: 8080"); System.out.println("Following services are available: "); server.getServices().stream() .forEach( s -> System.out.println("Service Name: " + s.getServiceDescriptor().getName()) ); server.awaitTermination(); ...Read now
Unlock full access