/** A simple client method that like {@link io.grpc.examples.helloworld.HelloWorldClient}. */
 private void greet(String name) {
   try {
     logger.info("Will try to greet " + name + " ...");
     HelloRequest request = HelloRequest.newBuilder().setName(name).build();
     HelloResponse response = blockingStub.sayHello(request);
     logger.info("Greeting: " + response.getMessage());
   } catch (RuntimeException e) {
     logger.log(Level.WARNING, "RPC failed", e);
   }
 }
示例#2
0
 @Override
 public void sayHello(HelloRequest req, StreamObserver<HelloResponse> responseObserver) {
   HelloResponse reply = HelloResponse.newBuilder().setMessage("Hello " + req.getName()).build();
   responseObserver.onValue(reply);
   responseObserver.onCompleted();
 }