You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by vi...@apache.org on 2019/08/22 03:13:28 UTC

[dubbo] 03/03: nacos test

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

victory pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git

commit 403858b8fb757617d71aeb59710e4264f5ed908f
Author: cvictory <sh...@gmail.com>
AuthorDate: Thu Aug 22 11:12:34 2019 +0800

    nacos test
---
 dubbo-bootstrap/pom.xml                                     | 13 +++++++++++++
 .../dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java |  9 ++++++---
 .../dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java |  9 ++++++---
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/dubbo-bootstrap/pom.xml b/dubbo-bootstrap/pom.xml
index 7cac061..9818a3a 100644
--- a/dubbo-bootstrap/pom.xml
+++ b/dubbo-bootstrap/pom.xml
@@ -40,6 +40,12 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-registry-nacos</artifactId>
+            <version>${project.parent.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
             <version>20.0</version>
@@ -68,6 +74,13 @@
 
         <dependency>
             <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-metadata-report-nacos</artifactId>
+            <version>${project.parent.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo-configcenter-zookeeper</artifactId>
             <version>${project.parent.version}</version>
             <scope>test</scope>
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java
index 873457e..1bddcd3 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceConsumerBootstrap.java
@@ -17,6 +17,7 @@
 package org.apache.dubbo.bootstrap;
 
 import org.apache.dubbo.bootstrap.rest.UserService;
+import org.apache.dubbo.config.ApplicationConfig;
 import org.apache.dubbo.config.MetadataReportConfig;
 import org.apache.dubbo.config.ReferenceConfig;
 import org.apache.dubbo.config.context.ConfigManager;
@@ -30,11 +31,13 @@ public class NacosDubboServiceConsumerBootstrap {
 
     public static void main(String[] args) throws Exception {
 
+        ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-nacos-consumer-demo");
+        applicationConfig.setMetadataType("remote");
         new DubboBootstrap()
-                .application("dubbo-consumer-demo")
+                .application(applicationConfig)
                 // Zookeeper
-                .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service&subscribed.services=dubbo-provider-demo"))
-                .metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
+                .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service&subscribed.services=dubbo-nacos-provider-demo"))
+                .metadataReport(new MetadataReportConfig("nacos://127.0.0.1:8848"))
                 // Nacos
 //                .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo").group("namespace1"))
                 .reference("echo", builder -> builder.interfaceClass(EchoService.class).protocol("dubbo"))
diff --git a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
index 4e0297c..bd47a7e 100644
--- a/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
+++ b/dubbo-bootstrap/src/test/java/org/apache/dubbo/bootstrap/NacosDubboServiceProviderBootstrap.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.bootstrap;
 
 import org.apache.dubbo.bootstrap.rest.UserService;
 import org.apache.dubbo.bootstrap.rest.UserServiceImpl;
+import org.apache.dubbo.config.ApplicationConfig;
 import org.apache.dubbo.config.MetadataReportConfig;
 
 /**
@@ -28,14 +29,16 @@ import org.apache.dubbo.config.MetadataReportConfig;
 public class NacosDubboServiceProviderBootstrap {
 
     public static void main(String[] args) {
+        ApplicationConfig applicationConfig = new ApplicationConfig("dubbo-nacos-provider-demo");
+        applicationConfig.setMetadataType("remote");
         new DubboBootstrap()
-                .application("dubbo-provider-demo")
+                .application(applicationConfig)
                 // Zookeeper in service registry type
-                .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry.type=service"))
+                .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service"))
                 // Nacos
 //                .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service"))
 //                .registry(RegistryBuilder.newBuilder().address("etcd3://127.0.0.1:2379?registry.type=service").build())
-                .metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
+                .metadataReport(new MetadataReportConfig("nacos://127.0.0.1:8848"))
                 .protocol("dubbo", builder -> builder.port(20885).name("dubbo"))
                 .protocol("rest", builder -> builder.port(9090).name("rest"))
                 .service(builder -> builder.id("echo").interfaceClass(EchoService.class).ref(new EchoServiceImpl()).protocolIds("dubbo"))