com.google.protobuf.RpcChannel Java Examples
The following examples show how to use
com.google.protobuf.RpcChannel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IntegrationTest.java From protobuf-socket-rpc with MIT License | 5 votes |
private void doTest(RpcServer rpcServer) throws InterruptedException, ServiceException, IOException { BlockingRpcChannel blockingChannel = RpcChannels .newBlockingRpcChannel(clientConnectionFactory); RpcChannel channel = RpcChannels.newRpcChannel(clientConnectionFactory, threadPool); BlockingInterface blockingStub = TestService .newBlockingStub(blockingChannel); TestService stub = TestService.newStub(channel); try { rpcServer.startServer(); Thread.sleep(500); doRpc(stub); doBlockingRpc(blockingStub); doBlockingRpc(blockingStub); doRpc(stub); } finally { Thread.sleep(500); System.out.println("Closing Client"); if (clientConnectionFactory instanceof Closeable) { ((PersistentRpcConnectionFactory) clientConnectionFactory).close(); } Thread.sleep(100); System.out.println("Closing Server"); rpcServer.shutDown(); } }
Example #2
Source File: ProtobufferExporterTest.java From fuchsia with Apache License 2.0 | 5 votes |
private AddressBookProtos.AddressBookService connectExportedProtobufAddress(ExportDeclaration declaration) throws EndpointException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, BinderException { ProtobufferExportDeclarationWrapper pojo = ProtobufferExportDeclarationWrapper.create(declaration); Bus cxfbus = BusFactory.getThreadDefaultBus(); BindingFactoryManager mgr = cxfbus.getExtension(BindingFactoryManager.class); mgr.registerBindingFactory(ProtobufBindingFactory.PROTOBUF_BINDING_ID, new ProtobufBindingFactory(cxfbus)); Class<?> bufferService = AddressBookProtos.AddressBookService.class; Class<?> bufferMessage = AddressBookProtos.AddressBookServiceMessage.class; Class<? extends Message> generic = bufferMessage.asSubclass(Message.class); RpcChannel channel = new SimpleRpcChannel(pojo.getAddress(), generic); Method method = bufferService.getMethod("newStub", RpcChannel.class); Object service = method.invoke(bufferService, channel); AddressBookProtos.AddressBookService addressBook = (AddressBookProtos.AddressBookService) service; return addressBook; }
Example #3
Source File: RpcChannels.java From protobuf-socket-rpc with MIT License | 2 votes |
/** * Create a {@link RpcChannel} that uses the given * {@link RpcConnectionFactory} to connect to the RPC server and the given * {@link Executor} to listen for the RPC response after sending the request. * RPCs made using this {@link RpcChannel} will not block the thread calling * the RPC method. Use {@link #newBlockingRpcChannel(RpcConnectionFactory)} if * you want the RPC method to block. * <p> * This channel doesn't call the callback if the server-side implementation * did not call the callback. If any error occurs, it will call the callback * with null and update the controller with the error. */ public static RpcChannel newRpcChannel( RpcConnectionFactory connectionFactory, Executor executor) { return new RpcChannelImpl(connectionFactory, executor); }