You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by li...@apache.org on 2020/08/04 07:09:43 UTC
[dubbo] 06/27: service discovery demo
This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
commit 193465525c3ddcfe7f10e3610880ac0d059e9277
Author: ken.lj <ke...@gmail.com>
AuthorDate: Tue Jun 16 00:39:08 2020 +0800
service discovery demo
---
.../java/org/apache/dubbo/demo/consumer/Application.java | 7 +++++--
.../src/main/resources/spring/dubbo-consumer.xml | 12 +++++++++---
.../src/main/resources/spring/dubbo-provider.xml | 7 +++++--
3 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
index 955d3eb..f637eb2 100644
--- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
+++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
@@ -31,7 +31,10 @@ public class Application {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
context.start();
DemoService demoService = context.getBean("demoService", DemoService.class);
- CompletableFuture<String> hello = demoService.sayHelloAsync("world");
- System.out.println("result: " + hello.get());
+ while (true) {
+ CompletableFuture<String> hello = demoService.sayHelloAsync("world");
+ System.out.println("result: " + hello.get());
+ Thread.sleep(500);
+ }
}
}
diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml
index 742195f..17aa9d6 100644
--- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml
+++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml
@@ -21,10 +21,16 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
- <dubbo:application name="demo-consumer"/>
+ <dubbo:application metadata-type="remote" name="demo-consumer">
+ <dubbo:parameter key="mapping-type" value="metadata"/>
+ </dubbo:application>
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>
- <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
+ <dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service"/>
+
+
+ <dubbo:reference provided-by="demo-provider" id="demoService" check="false"
+ interface="org.apache.dubbo.demo.DemoService"/>
</beans>
diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/spring/dubbo-provider.xml
index c809ff3..d7ab19a 100644
--- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/spring/dubbo-provider.xml
+++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-provider/src/main/resources/spring/dubbo-provider.xml
@@ -21,10 +21,13 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
- <dubbo:application metadata-type="remote" name="demo-provider"/>
+ <dubbo:application metadata-type="remote" name="demo-provider">
+ <dubbo:parameter key="mapping-type" value="metadata"/>
+ </dubbo:application>
+
<dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service"/>
<dubbo:protocol name="dubbo"/>