public interface MyService { Future<String> myMethod(String arg1, int arg2); } public class MyServiceImpl implements MyService { public Future<String> myMethod(String arg1, int arg2) { return Future.value("Result"); } } public class MyServer { public static void main(String[] args) { MyService myService = new MyServiceImpl(); ServerBuilder.safeBuild( new MyService$FinagleService(myService, new TBinaryProtocol.Factory()), ServerBuilder.get() .name("MyService") .bindTo(new InetSocketAddress(8080)) .codec(ThriftServerFramedCodec.get())); } } public class MyClient { public static void main(String[] args) { MyService.FutureIface myService = new MyService$FinagleClient(Thrift.client()); Future<String> result = myService.myMethod("arg1", 123); result.onSuccess(response -> { System.out.println("Result: " + response); }); } }


上一篇:
下一篇:
切换中文