Created
December 21, 2025 11:53
-
-
Save larkintuckerllc/e6b6aee45050a7cccf2f8ddfae8fcd19 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example; | |
| import io.grpc.ManagedChannel; | |
| import io.grpc.ManagedChannelBuilder; | |
| import io.grpc.StatusRuntimeException; | |
| public class GreeterClient { | |
| public static void main(String[] args) { | |
| String host = "localhost"; | |
| int port = 50051; | |
| ManagedChannel channel = ManagedChannelBuilder.forAddress(host, port).usePlaintext().build(); | |
| GreeterGrpc.GreeterBlockingStub blockingStub = GreeterGrpc.newBlockingStub(channel); | |
| HelloRequest request = HelloRequest.newBuilder().setName("World").build(); | |
| try { | |
| HelloReply response = blockingStub.sayHello(request); | |
| String message = response.getMessage(); | |
| System.out.println(message); | |
| } catch (StatusRuntimeException e) { | |
| System.err.println("RPC failed: " + e.getStatus()); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment