You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by li...@apache.org on 2019/05/10 05:56:16 UTC

[incubator-dubbo-samples] branch 3.x updated: add $asyncInvoke() sample

This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch 3.x
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-samples.git


The following commit(s) were added to refs/heads/3.x by this push:
     new 5a8e979  add $asyncInvoke() sample
5a8e979 is described below

commit 5a8e979d91a5f030af4370d7a832791ac5e85b23
Author: ken.lj <ke...@gmail.com>
AuthorDate: Fri May 10 13:56:04 2019 +0800

    add $asyncInvoke() sample
---
 .../samples/generic/call/GenericCallConsumer.java  | 28 +++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/dubbo-samples-generic/dubbo-samples-generic-call/dubbo-samples-generic-call-consumer/src/main/java/org/apache/dubbo/samples/generic/call/GenericCallConsumer.java b/dubbo-samples-generic/dubbo-samples-generic-call/dubbo-samples-generic-call-consumer/src/main/java/org/apache/dubbo/samples/generic/call/GenericCallConsumer.java
index c2be8c9..4ee98eb 100644
--- a/dubbo-samples-generic/dubbo-samples-generic-call/dubbo-samples-generic-call-consumer/src/main/java/org/apache/dubbo/samples/generic/call/GenericCallConsumer.java
+++ b/dubbo-samples-generic/dubbo-samples-generic-call/dubbo-samples-generic-call-consumer/src/main/java/org/apache/dubbo/samples/generic/call/GenericCallConsumer.java
@@ -41,12 +41,14 @@ public class GenericCallConsumer {
         applicationConfig.setRegistry(registryConfig);
         referenceConfig.setApplication(applicationConfig);
         referenceConfig.setGeneric(true);
-//        referenceConfig.setAsync(true);
+        referenceConfig.setAsync(true);
         referenceConfig.setTimeout(7000);
 
         genericService = referenceConfig.get();
-        $invokeWithNormalSignature();
-        $invokeWithAsyncSignature();
+//        $invokeWithNormalSignature();
+//        $invokeWithAsyncSignature();
+        $invokeAsyncWithAsyncSignature();
+        $invokeAsyncWithNormalSignature();
         System.in.read();
     }
 
@@ -72,4 +74,24 @@ public class GenericCallConsumer {
         System.out.println("...." + result);
     }
 
+    public static void $invokeAsyncWithAsyncSignature() throws Exception {
+        CompletableFuture<Object> future  = genericService.$invokeAsync("sayHelloAsync", new String[]{"java.lang.String"}, new Object[]{"world"});
+
+        future.whenComplete((value, t) -> {
+            System.err.println(value);
+        });
+
+        System.out.println(".... before return ...");
+    }
+
+    public static void $invokeAsyncWithNormalSignature() throws Exception {
+        CompletableFuture<Object> future  = genericService.$invokeAsync("sayHello", new String[]{"java.lang.String"}, new Object[]{"world"});
+
+        future.whenComplete((value, t) -> {
+            System.err.println(value);
+        });
+
+        System.out.println(".... before return ...");
+    }
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org