in 2-advanced/dubbo-samples-async/dubbo-samples-async-simple-boot/dubbo-samples-async-simple-boot-consumer/src/main/java/org/apache/dubbo/async/boot/consumer/Task.java [37:55]
public void run(String... args) throws Exception {
hiService.sayHello("world");//调用远程hiService 的sayHello
CompletableFuture<String> helloFuture = RpcContext.getContext().getCompletableFuture();
helloFuture.whenComplete((retValue, exception) -> {
if (exception == null) {
System.out.println("return value: " + retValue);
} else {
exception.printStackTrace();
}
});
CompletableFuture<String> f = RpcContext.getContext().asyncCall(() -> hiService.sayHello("async call request"));
System.out.println("async call returned: " + f.get());
RpcContext.getContext().asyncCall(() -> {
hiService.sayHello("one way call request1");
});
}