@Override public void start() throws Exception { // Create the channel ManagedChannel channel = VertxChannelBuilder .forAddress(vertx, "localhost", 8080) .usePlaintext(true) .build(); // Get a stub to use for interacting with the remote service EmptyPingPongServiceGrpc.EmptyPingPongServiceVertxStub stub = EmptyPingPongServiceGrpc.newVertxStub(channel); // Make a request EmptyProtos.Empty request = EmptyProtos.Empty.newBuilder().build(); // Call the remote service stub.emptyCall(request, ar -> { if (ar.succeeded()) { System.out.println("Got the server response."); } else { System.out.println("Coult not reach server " + ar.cause().getMessage()); } }); } }
@Override public void start() throws Exception { ManagedChannel channel = VertxChannelBuilder .forAddress(vertx, "localhost", 8080) .usePlaintext(true) .build(); GreeterGrpc.GreeterVertxStub stub = GreeterGrpc.newVertxStub(channel); HelloRequest request = HelloRequest.newBuilder().setName("Julien").build(); stub.sayHello(request, asyncResponse -> { if (asyncResponse.succeeded()) { System.out.println("Succeeded " + asyncResponse.result().getMessage()); } else { asyncResponse.cause().printStackTrace(); } }); } }
@Override public void start() throws Exception { // Create the channel ManagedChannel channel = VertxChannelBuilder .forAddress(vertx, "localhost", 8080) .usePlaintext(true) .build(); // Get a stub to use for interacting with the remote service PingPongServiceGrpc.PingPongServiceVertxStub stub = PingPongServiceGrpc.newVertxStub(channel); // Make a request Messages.SimpleRequest request = Messages.SimpleRequest.newBuilder().setFillUsername(true).build(); // Call the remote service stub.unaryCall(request, ar -> { if (ar.succeeded()) { System.out.println("My username is: " + ar.result().getUsername()); } else { System.out.println("Coult not reach server " + ar.cause().getMessage()); } }); } }
.forAddress(vertx, "localhost", 8080) .usePlaintext(true) .build();
@Override public void start() throws Exception { // Create the channel ManagedChannel channel = VertxChannelBuilder .forAddress(vertx, "localhost", 8080) .usePlaintext(true) .build(); // Get a stub to use for interacting with the remote service ConsumerServiceGrpc.ConsumerServiceVertxStub stub = ConsumerServiceGrpc.newVertxStub(channel); // Make a request Messages.StreamingOutputCallRequest request = Messages .StreamingOutputCallRequest .newBuilder() .build(); // Call the remote service stub.streamingOutputCall(request, stream -> { stream.handler(response -> { System.out .println(new String(response.getPayload().toByteArray(), Charset.forName("UTF-8"))); }).endHandler(v -> { System.out.println("Response has ended."); }); }); } }
@Override public void start() throws Exception { ManagedChannel channel = VertxChannelBuilder .forAddress(vertx, "localhost", 8080) .useSsl(options -> options.setSsl(true) .setUseAlpn(true) .setTrustStoreOptions(new JksOptions() .setPath("tls/client-truststore.jks") .setPassword("wibble"))) .build(); GreeterGrpc.GreeterVertxStub stub = GreeterGrpc.newVertxStub(channel); HelloRequest request = HelloRequest.newBuilder().setName("Julien").build(); stub.sayHello(request, asyncResponse -> { if (asyncResponse.succeeded()) { System.out.println("Succeeded " + asyncResponse.result().getMessage()); } else { asyncResponse.cause().printStackTrace(); } }); } }
@Override public void start() throws Exception { ManagedChannel channel = VertxChannelBuilder .forAddress(vertx, "localhost", 8080) .usePlaintext(true) .build(); stub = RouteGuideGrpc.newVertxStub(channel); List<Feature> features = Util.parseFeatures(Util.getDefaultFeaturesFile()); // Looking for a valid feature getFeature(409146138, -746188906); // Feature missing. getFeature(0, 0); // Looking for features between 40, -75 and 42, -73. listFeatures(400000000, -750000000, 420000000, -730000000); // Record a few randomly selected points from the features file. recordRoute(features, 10); routeChat(); }
@Override public void start() throws Exception { // Create the channel ManagedChannel channel = VertxChannelBuilder .forAddress(vertx, "localhost", 8080) .usePlaintext(true) .build(); // Get a stub to use for interacting with the remote service ConversationalServiceGrpc.ConversationalServiceVertxStub stub = ConversationalServiceGrpc.newVertxStub(channel); // Make a request Messages.StreamingOutputCallRequest request = Messages.StreamingOutputCallRequest.newBuilder().build(); // Call the remote service stub.fullDuplexCall(exchange -> { exchange .handler(req -> { System.out.println("Client: received response"); vertx.setTimer(500L, t -> { exchange.write(Messages.StreamingOutputCallRequest.newBuilder().build()); }); }); // start the conversation exchange.write(Messages.StreamingOutputCallRequest.newBuilder().build()); }); } }
final VertxChannelBuilder builder = VertxChannelBuilder .forAddress(vertx, rpcHost, rpcPort); Fn.safeSemi(null != config.getValue(Key.SSL), LOGGER, () -> { final JsonObject sslConfig = config.getJsonObject(Key.SSL);
private TestServiceVertxStub buildStub() { channel = VertxChannelBuilder.forAddress(vertx, "localhost", port).usePlaintext(true).build(); return newVertxStub(channel); }
final VertxChannelBuilder builder = VertxChannelBuilder .forAddress(vertx, rpcHost, rpcPort); Fn.safeSemi(null != config.getValue(Key.SSL), LOGGER, () -> { final JsonObject sslConfig = config.getJsonObject(Key.SSL);
@Test public void testCloseInVerticle(TestContext ctx) throws Exception { Async started = ctx.async(); vertx.deployVerticle(GrpcVerticle.class.getName(), ar1 -> { if (ar1.succeeded()) { vertx.undeploy(ar1.result(), ar2 -> { if (ar2.succeeded()) { started.complete(); } else { ctx.fail(ar2.cause()); } }); } else { ctx.fail(ar1.cause()); } }); started.awaitSuccess(10000); Async async = ctx.async(); ManagedChannel channel= VertxChannelBuilder.forAddress(vertx, "localhost", 50051) .usePlaintext(true) .build(); GreeterGrpc.GreeterVertxStub blockingStub = GreeterGrpc.newVertxStub(channel); HelloRequest request = HelloRequest.newBuilder().setName("Julien").build(); blockingStub.sayHello(request, ar -> { ctx.assertFalse(ar.succeeded()); async.complete(); channel.shutdown(); }); }
final VertxChannelBuilder builder = VertxChannelBuilder .forAddress(vertx, grpcHost, grpcPort);
final VertxChannelBuilder builder = VertxChannelBuilder .forAddress(vertx, grpcHost, grpcPort);
Async async = ctx.async(num); for (int i = 0;i < num;i++) { ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "localhost", 50051) .usePlaintext(true) .build();
ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "localhost", port) .usePlaintext(true) .build();
ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "localhost", port) .usePlaintext(true) .build();
ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "localhost", port) .usePlaintext(true) .build();
Context clientCtx = vertx.getOrCreateContext(); clientCtx.runOnContext(v -> { ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "localhost", port) .usePlaintext(true) .build();
started.awaitSuccess(10000); Async async = ctx.async(); ManagedChannel channel = VertxChannelBuilder.forAddress(vertx, "localhost", port) .usePlaintext(true) .build();