use of org.baeldung.grpc.HelloResponse in project tutorials by eugenp.
the class GrpcClient method main.
public static void main(String[] args) throws InterruptedException {
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 8080).usePlaintext(true).build();
HelloServiceGrpc.HelloServiceBlockingStub stub = HelloServiceGrpc.newBlockingStub(channel);
HelloResponse helloResponse = stub.hello(HelloRequest.newBuilder().setFirstName("Baeldung").setLastName("gRPC").build());
System.out.println("Response received from server:\n" + helloResponse);
channel.shutdown();
}
use of org.baeldung.grpc.HelloResponse in project tutorials by eugenp.
the class HelloServiceImpl method hello.
@Override
public void hello(HelloRequest request, StreamObserver<HelloResponse> responseObserver) {
System.out.println("Request received from client:\n" + request);
String greeting = new StringBuilder().append("Hello, ").append(request.getFirstName()).append(" ").append(request.getLastName()).toString();
HelloResponse response = HelloResponse.newBuilder().setGreeting(greeting).build();
responseObserver.onNext(response);
responseObserver.onCompleted();
}
Aggregations