You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2020/05/27 01:41:03 UTC

[servicecomb-java-chassis] branch master updated (40d2aa0 -> 4cc3834)

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

liubao pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git.


    from 40d2aa0  [SCB-1937] fix integration test(TestAsyncInvoke) always timeout problem
     new 2eac3a4  [SCB-1935]add a demo to show using local registry and service center together
     new 5af49a4  [SCB-1935]publish service center port to local access
     new 4cc3834  [SCB-1935]reorganize test case

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../demo-multi-registries-client}/pom.xml          | 10 ++--
 .../servicecomb/demo/registry/Application.java     | 14 ++---
 .../demo/registry/IServiceCenterEndpoint.java      | 17 +++---
 .../registry/MultiRegistriesServerTestCase.java}   | 36 +++++++------
 .../demo/registry/ServiceCenterEndpoint.java}      | 26 +++++-----
 .../demo/registry/ServiceCenterTestCase.java       | 60 ++++++++++++++++++++++
 .../src/main/resources/application.yml             |  4 +-
 .../src/main/resources/logback.xml                 |  0
 .../ServiceCenterEndpoint.yaml}                    | 42 ++++++++++-----
 .../src/main/resources/registry.yaml               | 10 ++--
 .../demo/registry/MultiRegistriesIT.java}          |  2 +-
 .../demo-multi-registries-server}/pom.xml          |  6 +--
 .../demo/registry/SelfServiceInvoker.java          |  2 +-
 .../demo/registry/ServerApplication.java           |  0
 .../servicecomb/demo/registry/ServerEndpoint.java  |  0
 .../src/main/resources/application.yml             | 12 ++---
 .../src/main/resources/logback.xml                 |  0
 .../pom.xml                                        | 12 +++--
 .../servicecomb/demo/CategorizedTestCase.java      |  4 ++
 .../demo/CategorizedTestCaseRunner.java            |  8 ++-
 demo/docker-run-config-edge/pom.xml                |  4 +-
 demo/docker-run-config-local/pom.xml               | 31 -----------
 demo/docker-run-config/pom.xml                     |  4 +-
 demo/pom.xml                                       |  1 +
 .../serviceregistry/DiscoveryManager.java          |  7 ++-
 .../serviceregistry/RegistrationManager.java       |  1 +
 .../serviceregistry/{ => api}/Discovery.java       | 21 +++++---
 .../serviceregistry/{ => api}/LifeCycle.java       |  2 +-
 .../serviceregistry/{ => api}/Registration.java    |  2 +-
 .../client/http/MicroserviceInstances.java         | 18 +++++--
 .../servicecomb/localregistry/LocalDiscovery.java  |  4 +-
 .../localregistry/LocalRegistration.java           |  2 +-
 ...ache.servicecomb.serviceregistry.api.Discovery} |  0
 ...e.servicecomb.serviceregistry.api.Registration} |  0
 .../serviceregistry/ServiceCenterDiscovery.java    |  4 +-
 .../serviceregistry/ServiceCenterRegistration.java |  1 +
 .../client/http/ServiceRegistryClientImpl.java     |  1 +
 ...ache.servicecomb.serviceregistry.api.Discovery} |  0
 ...e.servicecomb.serviceregistry.api.Registration} |  0
 39 files changed, 227 insertions(+), 141 deletions(-)
 copy demo/{demo-local-registry/demo-local-registry-client => demo-multi-registries/demo-multi-registries-client}/pom.xml (88%)
 copy demo/{demo-local-registry/demo-local-registry-client => demo-multi-registries/demo-multi-registries-client}/src/main/java/org/apache/servicecomb/demo/registry/Application.java (80%)
 copy swagger/swagger-invocation/invocation-core/src/test/java/org/apache/servicecomb/swagger/invocation/schemas/SpringmvcAddV2.java => demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/IServiceCenterEndpoint.java (62%)
 copy demo/{demo-register-url-prefix/demo-register-url-prefix-client/src/main/java/org/apache/servicecomb/demo/prefix/Application.java => demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/MultiRegistriesServerTestCase.java} (57%)
 copy demo/{demo-local-registry/demo-local-registry-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java => demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterEndpoint.java} (63%)
 create mode 100644 demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterTestCase.java
 copy demo/{demo-register-url-prefix/demo-register-url-prefix-client => demo-multi-registries/demo-multi-registries-client}/src/main/resources/application.yml (91%)
 copy demo/{demo-register-url-prefix/demo-register-url-prefix-server => demo-multi-registries/demo-multi-registries-client}/src/main/resources/logback.xml (100%)
 copy demo/{demo-local-registry/demo-local-registry-client/src/main/resources/microservices/demo-local-registry-server/ServerEndpoint.yaml => demo-multi-registries/demo-multi-registries-client/src/main/resources/microservices/thirdParty-service-center/ServiceCenterEndpoint.yaml} (61%)
 copy demo/{demo-local-registry/demo-local-registry-client => demo-multi-registries/demo-multi-registries-client}/src/main/resources/registry.yaml (87%)
 copy demo/{demo-local-registry/demo-local-registry-client/src/test/java/org/apache/servicecomb/demo/registry/LocalRegistryIT.java => demo-multi-registries/demo-multi-registries-client/src/test/java/org/apache/servicecomb/demo/registry/MultiRegistriesIT.java} (97%)
 copy demo/{demo-local-registry/demo-local-registry-server => demo-multi-registries/demo-multi-registries-server}/pom.xml (95%)
 copy demo/{demo-local-registry/demo-local-registry-server => demo-multi-registries/demo-multi-registries-server}/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java (93%)
 copy demo/{demo-local-registry/demo-local-registry-server => demo-multi-registries/demo-multi-registries-server}/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java (100%)
 copy demo/{demo-local-registry/demo-local-registry-server => demo-multi-registries/demo-multi-registries-server}/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java (100%)
 copy demo/{demo-spring-boot-transport/demo-spring-boot-pojo-server => demo-multi-registries/demo-multi-registries-server}/src/main/resources/application.yml (87%)
 copy demo/{demo-register-url-prefix/demo-register-url-prefix-server => demo-multi-registries/demo-multi-registries-server}/src/main/resources/logback.xml (100%)
 copy demo/{demo-spring-boot-transport => demo-multi-registries}/pom.xml (84%)
 rename foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/{ => api}/Discovery.java (74%)
 rename foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/{ => api}/LifeCycle.java (94%)
 rename foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/{ => api}/Registration.java (97%)
 rename service-registry/registry-local/src/main/resources/META-INF/services/{org.apache.servicecomb.serviceregistry.Discovery => org.apache.servicecomb.serviceregistry.api.Discovery} (100%)
 rename service-registry/registry-local/src/main/resources/META-INF/services/{org.apache.servicecomb.serviceregistry.Registration => org.apache.servicecomb.serviceregistry.api.Registration} (100%)
 rename service-registry/registry-service-center/src/main/resources/META-INF/services/{org.apache.servicecomb.serviceregistry.Discovery => org.apache.servicecomb.serviceregistry.api.Discovery} (100%)
 rename service-registry/registry-service-center/src/main/resources/META-INF/services/{org.apache.servicecomb.serviceregistry.Registration => org.apache.servicecomb.serviceregistry.api.Registration} (100%)


[servicecomb-java-chassis] 01/03: [SCB-1935]add a demo to show using local registry and service center together

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git

commit 2eac3a466822d29f272fe236337d18a987f0eb06
Author: liubao <bi...@qq.com>
AuthorDate: Tue May 26 17:43:41 2020 +0800

    [SCB-1935]add a demo to show using local registry and service center together
---
 .../demo-multi-registries-client/pom.xml           |  78 ++++++++++++++++
 .../servicecomb/demo/registry/Application.java     |  67 ++++++++++++++
 .../demo/registry/IServiceCenterEndpoint.java      |  18 ++--
 .../demo/registry/ServiceCenterEndpoint.java       |  40 +++++++++
 .../src/main/resources/application.yml             |  34 +++++++
 .../src/main/resources/logback.xml                 |  50 +++++++++++
 .../ServiceCenterEndpoint.yaml                     |  59 ++++++++++++
 .../src/main/resources/registry.yaml               |  26 ++++++
 .../demo/registry/MultiRegistriesIT.java           |  23 +++--
 .../demo-multi-registries-server/pom.xml           | 100 +++++++++++++++++++++
 .../demo/registry/SelfServiceInvoker.java          |  27 ++++--
 .../demo/registry/ServerApplication.java           |  44 +++++++++
 .../servicecomb/demo/registry/ServerEndpoint.java  |  42 +++++++++
 .../src/main/resources/application.yml             |  32 +++++++
 .../src/main/resources/logback.xml                 |  50 +++++++++++
 demo/demo-multi-registries/pom.xml                 |  54 +++++++++++
 demo/pom.xml                                       |   1 +
 .../serviceregistry/DiscoveryManager.java          |   7 +-
 .../serviceregistry/RegistrationManager.java       |   1 +
 .../serviceregistry/{ => api}/Discovery.java       |  21 +++--
 .../serviceregistry/{ => api}/LifeCycle.java       |   2 +-
 .../serviceregistry/{ => api}/Registration.java    |   2 +-
 .../client/http/MicroserviceInstances.java         |  18 ++--
 .../servicecomb/localregistry/LocalDiscovery.java  |   4 +-
 .../localregistry/LocalRegistration.java           |   2 +-
 ...ache.servicecomb.serviceregistry.api.Discovery} |   0
 ...e.servicecomb.serviceregistry.api.Registration} |   0
 .../serviceregistry/ServiceCenterDiscovery.java    |   4 +-
 .../serviceregistry/ServiceCenterRegistration.java |   1 +
 .../client/http/ServiceRegistryClientImpl.java     |   1 +
 ...ache.servicecomb.serviceregistry.api.Discovery} |   0
 ...e.servicecomb.serviceregistry.api.Registration} |   0
 32 files changed, 772 insertions(+), 36 deletions(-)

diff --git a/demo/demo-multi-registries/demo-multi-registries-client/pom.xml b/demo/demo-multi-registries/demo-multi-registries-client/pom.xml
new file mode 100644
index 0000000..539ede0
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>demo-multi-registries-client</artifactId>
+  <name>Java Chassis::Demo::Multi Registries client</name>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-multi-registries</artifactId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+
+  <properties>
+    <demo.main>org.apache.servicecomb.demo.registry.Application</demo.main>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.demo</groupId>
+      <artifactId>demo-schema</artifactId>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>com.github.odavid.maven.plugins</groupId>
+        <artifactId>mixin-maven-plugin</artifactId>
+        <configuration>
+          <mixins>
+            <mixin>
+              <groupId>org.apache.servicecomb.demo</groupId>
+              <artifactId>docker-run-config</artifactId>
+              <version>${project.version}</version>
+            </mixin>
+          </mixins>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>docker</id>
+      <properties>
+        <demo.service.name>demo-multi-registries-server</demo.service.name>
+      </properties>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>io.fabric8</groupId>
+            <artifactId>docker-maven-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
new file mode 100644
index 0000000..2ef836c
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.demo.registry;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootApplication
+@EnableServiceComb
+@Component
+public class Application {
+  @RpcReference(microserviceName = "thirdParty-service-center", schemaId = "ServiceCenterEndpoint")
+  static IServiceCenterEndpoint serviceCenterEndpoint;
+
+  public static void main(final String[] args) throws Exception {
+    new SpringApplicationBuilder().sources(Application.class).web(WebApplicationType.SERVLET).build().run(args);
+
+    runTest();
+  }
+
+  public static void runTest() {
+    RestTemplate template = RestTemplateBuilder.create();
+
+    // invoke demo-multi-registries-server
+    TestMgr.check("2", template
+        .getForObject("cse://demo-multi-registries-server/register/url/prefix/getName?name=2",
+            String.class));
+
+    // invoke service-center(3rd-parties)
+    @SuppressWarnings("unchecked")
+    Map<String, List<?>> result = (Map<String, List<?>>) serviceCenterEndpoint.getInstances("demo-multi-registries",
+        "demo-multi-registries-server",
+        "true",
+        "0.0.2",
+        "default");
+    TestMgr.check(result.get("instances").size(), 1);
+    TestMgr.summary();
+    if (!TestMgr.errors().isEmpty()) {
+      throw new IllegalStateException("tests failed");
+    }
+  }
+}
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/IServiceCenterEndpoint.java
similarity index 54%
copy from foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
copy to demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/IServiceCenterEndpoint.java
index 2e0b4af..4287894 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/IServiceCenterEndpoint.java
@@ -15,12 +15,18 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.demo.registry;
 
-public interface LifeCycle {
-  void init();
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestParam;
 
-  void run();
-
-  void destroy();
+public interface IServiceCenterEndpoint {
+  // java name can not be `x-domain-name`, so interfaces define all parameters.
+  @GetMapping(path = "/instances")
+  Object getInstances(@RequestParam(name = "appId") String appId,
+      @RequestParam(name = "serviceName") String serviceName,
+      @RequestParam(name = "global") String global,
+      @RequestParam(name = "version") String version,
+      @RequestHeader(name = "x-domain-name") String domain);
 }
diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterEndpoint.java b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterEndpoint.java
new file mode 100644
index 0000000..ceba6f4
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterEndpoint.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.demo.registry;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+// do not know how to write schemas? code first and generate it.
+@RestSchema(schemaId = "ServiceCenterEndpoint")
+@RequestMapping(path = "/v4/default/registry", produces = MediaType.APPLICATION_JSON)
+public class ServiceCenterEndpoint implements IServiceCenterEndpoint {
+  @GetMapping(path = "/instances")
+  public Object getInstances(@RequestParam(name = "appId") String appId,
+      @RequestParam(name = "serviceName") String serviceName,
+      @RequestParam(name = "global") String global,
+      @RequestParam(name = "version") String version,
+      @RequestHeader(name = "x-domain-name") String domain) {
+    return null;
+  }
+}
diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/application.yml b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/application.yml
new file mode 100644
index 0000000..257e90b
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/application.yml
@@ -0,0 +1,34 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+server:
+  port: 8082
+
+# java-chassis configurations
+
+APPLICATION_ID: demo-multi-registries
+service_description:
+  name: demo-multi-registries-client
+  version: 0.0.1
+servicecomb:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+  handler:
+    chain:
+      Consumer:
+        default: loadbalance
\ No newline at end of file
diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/logback.xml b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/logback.xml
new file mode 100644
index 0000000..0d627f2
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/logback.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<configuration scan="true">
+  <appender name="STDOUT-TRACING" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>DENY</OnMismatch>
+      <OnMatch>ACCEPT</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread][%X{SERVICECOMB_TRACE_ID}] - %msg (%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>ACCEPT</OnMismatch>
+      <OnMatch>DENY</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread] - %msg (%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="info">
+    <appender-ref ref="STDOUT"/>
+    <appender-ref ref="STDOUT-TRACING"/>
+  </root>
+</configuration>
\ No newline at end of file
diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/microservices/thirdParty-service-center/ServiceCenterEndpoint.yaml b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/microservices/thirdParty-service-center/ServiceCenterEndpoint.yaml
new file mode 100644
index 0000000..8ba87fa
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/microservices/thirdParty-service-center/ServiceCenterEndpoint.yaml
@@ -0,0 +1,59 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+swagger: "2.0"
+info:
+  version: "1.0.0"
+  title: "swagger definition for org.apache.servicecomb.demo.registry.ServiceCenterEndpoint"
+  x-java-interface: "gen.swagger.ServiceCenterEndpointIntf"
+basePath: "/v4/default/registry"
+schemes:
+  - "http"
+consumes:
+  - "application/json"
+produces:
+  - "application/json"
+paths:
+  /instances:
+    get:
+      operationId: "getInstances"
+      parameters:
+        - name: "appId"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "serviceName"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "global"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "version"
+          in: "query"
+          required: true
+          type: "string"
+        - name: "x-domain-name"
+          in: "header"
+          required: true
+          type: "string"
+      responses:
+        "200":
+          description: "response of 200"
+          schema:
+            type: "object"
\ No newline at end of file
diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/registry.yaml b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/registry.yaml
new file mode 100644
index 0000000..00d4588
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/resources/registry.yaml
@@ -0,0 +1,26 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+thirdParty-service-center:
+  - id: "001"
+    version: "4.0.0"
+    appid: demo-multi-registries
+    schemaIds:
+      - ServiceCenterEndpoint
+    instances:
+      - endpoints:
+          - rest://localhost:30100
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java b/demo/demo-multi-registries/demo-multi-registries-client/src/test/java/org/apache/servicecomb/demo/registry/MultiRegistriesIT.java
similarity index 61%
copy from foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
copy to demo/demo-multi-registries/demo-multi-registries-client/src/test/java/org/apache/servicecomb/demo/registry/MultiRegistriesIT.java
index 2e0b4af..e50d92a 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/test/java/org/apache/servicecomb/demo/registry/MultiRegistriesIT.java
@@ -15,12 +15,25 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.demo.registry;
 
-public interface LifeCycle {
-  void init();
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
 
-  void run();
+import org.apache.servicecomb.demo.TestMgr;
+import org.junit.Before;
+import org.junit.Test;
 
-  void destroy();
+public class MultiRegistriesIT {
+  @Before
+  public void setUp() throws Exception {
+    TestMgr.errors().clear();
+  }
+
+  @Test
+  public void clientGetsNoError() throws Exception {
+    Application.main(new String[0]);
+
+    assertThat(TestMgr.errors().isEmpty(), is(true));
+  }
 }
diff --git a/demo/demo-multi-registries/demo-multi-registries-server/pom.xml b/demo/demo-multi-registries/demo-multi-registries-server/pom.xml
new file mode 100644
index 0000000..41961ec
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-server/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>demo-multi-registries-server</artifactId>
+  <name>Java Chassis::Demo::Multi Registries Server</name>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-multi-registries</artifactId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+
+  <properties>
+    <demo.main>org.apache.servicecomb.demo.registry.ServerApplication</demo.main>
+  </properties>
+  <dependencies>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-commons</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-context</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework.cloud</groupId>
+      <artifactId>spring-cloud-netflix-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.ws.rs</groupId>
+      <artifactId>javax.ws.rs-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb.demo</groupId>
+      <artifactId>demo-schema</artifactId>
+    </dependency>
+
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>com.github.odavid.maven.plugins</groupId>
+        <artifactId>mixin-maven-plugin</artifactId>
+        <configuration>
+          <mixins>
+            <mixin>
+              <groupId>org.apache.servicecomb.demo</groupId>
+              <artifactId>docker-build-config</artifactId>
+              <version>${project.version}</version>
+            </mixin>
+          </mixins>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>docker</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>io.fabric8</groupId>
+            <artifactId>docker-maven-plugin</artifactId>
+          </plugin>
+          <plugin>
+            <groupId>org.commonjava.maven.plugins</groupId>
+            <artifactId>directory-maven-plugin</artifactId>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
similarity index 52%
copy from foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
copy to demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
index 2e0b4af..b15bb7c 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
+++ b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/SelfServiceInvoker.java
@@ -15,12 +15,29 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.demo.registry;
 
-public interface LifeCycle {
-  void init();
+import java.util.concurrent.CountDownLatch;
 
-  void run();
+import org.apache.servicecomb.core.BootListener;
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.springframework.stereotype.Component;
 
-  void destroy();
+@Component("SelfServiceInvoker")
+public class SelfServiceInvoker implements BootListener {
+  interface IServerEndpoint {
+    String getName(String name);
+  }
+
+  @RpcReference(microserviceName = "demo-multi-registries-server", schemaId = "ServerEndpoint")
+  IServerEndpoint endpoint;
+
+  public CountDownLatch latch = new CountDownLatch(1);
+
+  public String result = "";
+
+  public void onAfterRegistry(BootEvent event) {
+    result = endpoint.getName("hello");
+    latch.countDown();
+  }
 }
diff --git a/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
new file mode 100644
index 0000000..7d53303
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerApplication.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.demo.registry;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.foundation.common.utils.BeanUtils;
+import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
+import org.springframework.boot.WebApplicationType;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+
+@SpringBootApplication
+@EnableServiceComb
+public class ServerApplication {
+  public static void main(final String[] args) throws Exception {
+    new SpringApplicationBuilder().sources(ServerApplication.class).web(WebApplicationType.SERVLET).build().run(args);
+
+    SelfServiceInvoker invoker = BeanUtils.getBean("SelfServiceInvoker");
+    invoker.latch.await(10, TimeUnit.SECONDS);
+    TestMgr.check(invoker.result, "hello");
+
+    TestMgr.summary();
+    if (!TestMgr.errors().isEmpty()) {
+      System.exit(1);
+    }
+  }
+}
diff --git a/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java
new file mode 100644
index 0000000..595997f
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-server/src/main/java/org/apache/servicecomb/demo/registry/ServerEndpoint.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.demo.registry;
+
+import javax.ws.rs.core.MediaType;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+@RestSchema(schemaId = "ServerEndpoint")
+@RequestMapping(path = "/register/url/prefix", produces = MediaType.APPLICATION_JSON)
+public class ServerEndpoint {
+  private static final Logger LOGGER
+      = LoggerFactory.getLogger(ServerEndpoint.class);
+
+  @GetMapping(path = "/getName")
+  public String getName(@RequestParam(name = "name") String name) {
+    ((Invocation) ContextUtils.getInvocationContext()).getTraceIdLogger().info(LOGGER, "get name invoked.");
+    return name;
+  }
+}
diff --git a/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/application.yml b/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/application.yml
new file mode 100644
index 0000000..7658315
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/application.yml
@@ -0,0 +1,32 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License.  You may obtain a copy of the License at
+##
+##      http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+server:
+  port: 8080
+
+# java-chassis configurations
+
+APPLICATION_ID: demo-multi-registries
+service_description:
+  name: demo-multi-registries-server
+  version: 0.0.2
+servicecomb:
+  service:
+    registry:
+      address: http://127.0.0.1:30100
+  rest:
+    address: 0.0.0.0:8080
\ No newline at end of file
diff --git a/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/logback.xml b/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/logback.xml
new file mode 100644
index 0000000..0d627f2
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-server/src/main/resources/logback.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<configuration scan="true">
+  <appender name="STDOUT-TRACING" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>DENY</OnMismatch>
+      <OnMatch>ACCEPT</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread][%X{SERVICECOMB_TRACE_ID}] - %msg (%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+    <!-- If applicable, can use ch.qos.logback.classic.filter.MarkerFilter -->
+    <filter class="org.apache.servicecomb.foundation.logback.MarkerFilter">
+      <Marker>SERVICECOMB_MARKER</Marker>
+      <OnMismatch>ACCEPT</OnMismatch>
+      <OnMatch>DENY</OnMatch>
+    </filter>
+
+    <encoder>
+      <pattern>%d [%level] [%thread] - %msg (%F:%L\)%n</pattern>
+    </encoder>
+  </appender>
+
+  <root level="info">
+    <appender-ref ref="STDOUT"/>
+    <appender-ref ref="STDOUT-TRACING"/>
+  </root>
+</configuration>
\ No newline at end of file
diff --git a/demo/demo-multi-registries/pom.xml b/demo/demo-multi-registries/pom.xml
new file mode 100644
index 0000000..d238442
--- /dev/null
+++ b/demo/demo-multi-registries/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.servicecomb.demo</groupId>
+    <artifactId>demo-parent</artifactId>
+    <version>2.1.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>demo-multi-registries</artifactId>
+  <name>Java Chassis::Demo::Multi Registry</name>
+  <packaging>pom</packaging>
+  <modules>
+    <module>demo-multi-registries-server</module>
+    <module>demo-multi-registries-client</module>
+  </modules>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>java-chassis-spring-boot-starter-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-local</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>registry-service-center</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.servicecomb</groupId>
+      <artifactId>foundation-test-scaffolding</artifactId>
+      <scope>compile</scope>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/demo/pom.xml b/demo/pom.xml
index 68b912a..c0d40fc 100644
--- a/demo/pom.xml
+++ b/demo/pom.xml
@@ -42,6 +42,7 @@
     <module>demo-crossapp</module>
     <module>demo-register-url-prefix</module>
     <module>demo-local-registry</module>
+    <module>demo-multi-registries</module>
     <module>demo-spring-boot-provider</module>
     <module>demo-spring-boot-transport</module>
     <module>demo-edge</module>
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/DiscoveryManager.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/DiscoveryManager.java
index 474a9d9..f6439d1 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/DiscoveryManager.java
+++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/DiscoveryManager.java
@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
 import org.apache.servicecomb.config.ConfigUtil;
 import org.apache.servicecomb.config.archaius.sources.MicroserviceConfigLoader;
 import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.apache.servicecomb.serviceregistry.api.Discovery;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import org.apache.servicecomb.serviceregistry.cache.InstanceCacheManager;
@@ -65,7 +66,9 @@ public class DiscoveryManager {
   public MicroserviceInstances findServiceInstances(String appId, String serviceName,
       String versionRule) {
     MicroserviceInstances result = new MicroserviceInstances();
-
+    // default values not suitable for aggregate, reset.
+    result.setNeedRefresh(false);
+    result.setMicroserviceNotExist(true);
     discoveryList
         .forEach(discovery -> {
           MicroserviceInstances microserviceInstances = discovery.findServiceInstances(appId, serviceName, versionRule);
@@ -86,7 +89,7 @@ public class DiscoveryManager {
 
   public MicroserviceInstance findMicroserviceInstance(String serviceId, String instanceId) {
     for (Discovery discovery : discoveryList) {
-      MicroserviceInstance microserviceInstance = discovery.findMicroserviceInstance(serviceId, instanceId);
+      MicroserviceInstance microserviceInstance = discovery.getMicroserviceInstance(serviceId, instanceId);
       if (microserviceInstance != null) {
         return microserviceInstance;
       }
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistrationManager.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistrationManager.java
index dc50329..2ed54a5 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistrationManager.java
+++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/RegistrationManager.java
@@ -28,6 +28,7 @@ import org.apache.http.client.utils.URIBuilder;
 import org.apache.servicecomb.foundation.common.net.IpPort;
 import org.apache.servicecomb.foundation.common.net.NetUtils;
 import org.apache.servicecomb.foundation.common.utils.SPIServiceUtils;
+import org.apache.servicecomb.serviceregistry.api.Registration;
 import org.apache.servicecomb.serviceregistry.api.registry.BasePath;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Discovery.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Discovery.java
similarity index 74%
rename from foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Discovery.java
rename to foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Discovery.java
index f94ef33..3a74602 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Discovery.java
+++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Discovery.java
@@ -15,24 +15,33 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.serviceregistry.api;
 
 import org.apache.servicecomb.foundation.common.utils.SPIEnabled;
 import org.apache.servicecomb.foundation.common.utils.SPIOrder;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
-import org.apache.servicecomb.serviceregistry.consumer.MicroserviceVersions;
 
+/**
+ * This is the core registry discovery interface. <br/>
+ */
 public interface Discovery extends SPIEnabled, SPIOrder, LifeCycle {
-  // TODO: microservice id may be different in Discovery, maybe better to use appId, serviceName and version.
   Microservice getMicroservice(String microserviceId);
 
-  // TODO: microservice id may be different in Discovery, maybe better to use appId, serviceName and version.
   String getSchema(String microserviceId, String schemaId);
 
-  MicroserviceInstance findMicroserviceInstance(String serviceId, String instanceId);
-
+  MicroserviceInstance getMicroserviceInstance(String serviceId, String instanceId);
+
+  /**
+   * Find all instances. Implementations can use <code>gerRevision</code> to retrieve the
+   * latest instances changed.
+   *
+   * @param appId application id
+   * @param serviceName microservice name
+   * @param versionRule literal version rule. e.g. 1.0.0, 1.0.0+, [1.0.0, 2.0.0)
+   * @return all instances match the criteria.
+   */
   MicroserviceInstances findServiceInstances(String appId, String serviceName,
       String versionRule);
 
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/LifeCycle.java
similarity index 94%
rename from foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
rename to foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/LifeCycle.java
index 2e0b4af..f584dea 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/LifeCycle.java
+++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/LifeCycle.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.serviceregistry.api;
 
 public interface LifeCycle {
   void init();
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Registration.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Registration.java
similarity index 97%
rename from foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Registration.java
rename to foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Registration.java
index 631ff01..3a925e6 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/Registration.java
+++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/api/Registration.java
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.servicecomb.serviceregistry;
+package org.apache.servicecomb.serviceregistry.api;
 
 import java.util.Collection;
 
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/MicroserviceInstances.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/MicroserviceInstances.java
index 218d555..86b8537 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/MicroserviceInstances.java
+++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/serviceregistry/client/http/MicroserviceInstances.java
@@ -69,30 +69,38 @@ public class MicroserviceInstances {
   }
 
   private void mergeRevision(String revision) {
+    if (revision == null) {
+      return;
+    }
     if (this.revision == null || this.revision.compareTo(revision) < 0) {
       this.revision = revision;
     }
   }
 
   private void mergeMicroserviceNotExist(boolean microserviceNotExist) {
-    // if one of discovery not exist, all mark not exist
-    if (microserviceNotExist) {
+    // only is all not exists, set to not exits.
+    if (this.microserviceNotExist) {
       this.microserviceNotExist = microserviceNotExist;
     }
   }
 
   private void mergeNeedRefresh(boolean needRefresh) {
     // if one of discovery need refresh, all need refresh
-    if (needRefresh) {
+    if (!this.needRefresh) {
       this.needRefresh = needRefresh;
     }
   }
 
   private void mergeInstanceResponse(FindInstancesResponse instancesResponse) {
+    if (instancesResponse == null) {
+      return;
+    }
+
     if (this.instancesResponse == null) {
       this.instancesResponse = instancesResponse;
-    } else {
-      this.instancesResponse.mergeInstances(instancesResponse.getInstances());
+      return;
     }
+
+    this.instancesResponse.mergeInstances(instancesResponse.getInstances());
   }
 }
diff --git a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
index 7750b03..b6ac786 100644
--- a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
+++ b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalDiscovery.java
@@ -17,7 +17,7 @@
 
 package org.apache.servicecomb.localregistry;
 
-import org.apache.servicecomb.serviceregistry.Discovery;
+import org.apache.servicecomb.serviceregistry.api.Discovery;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
@@ -64,7 +64,7 @@ public class LocalDiscovery implements Discovery {
   }
 
   @Override
-  public MicroserviceInstance findMicroserviceInstance(String serviceId, String instanceId) {
+  public MicroserviceInstance getMicroserviceInstance(String serviceId, String instanceId) {
     return localDiscoveryStore.findMicroserviceInstance(serviceId, instanceId);
   }
 
diff --git a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
index 3d10844..912a9bd 100644
--- a/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
+++ b/service-registry/registry-local/src/main/java/org/apache/servicecomb/localregistry/LocalRegistration.java
@@ -20,7 +20,7 @@ package org.apache.servicecomb.localregistry;
 import java.util.Collection;
 
 import org.apache.servicecomb.foundation.common.event.EventManager;
-import org.apache.servicecomb.serviceregistry.Registration;
+import org.apache.servicecomb.serviceregistry.api.Registration;
 import org.apache.servicecomb.serviceregistry.api.registry.BasePath;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
diff --git a/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery b/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Discovery
similarity index 100%
rename from service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
rename to service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Discovery
diff --git a/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration b/service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Registration
similarity index 100%
rename from service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
rename to service-registry/registry-local/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Registration
diff --git a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
index 797673b..7518512 100644
--- a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
+++ b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterDiscovery.java
@@ -17,10 +17,10 @@
 
 package org.apache.servicecomb.serviceregistry;
 
+import org.apache.servicecomb.serviceregistry.api.Discovery;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import org.apache.servicecomb.serviceregistry.client.http.MicroserviceInstances;
-import org.apache.servicecomb.serviceregistry.definition.DefinitionConst;
 
 import com.netflix.config.DynamicPropertyFactory;
 
@@ -63,7 +63,7 @@ public class ServiceCenterDiscovery implements Discovery {
   }
 
   @Override
-  public MicroserviceInstance findMicroserviceInstance(String serviceId, String instanceId) {
+  public MicroserviceInstance getMicroserviceInstance(String serviceId, String instanceId) {
     return RegistryUtils.getResultFromFirstValidServiceRegistry(
         sr -> sr.getServiceRegistryClient().findServiceInstance(serviceId, instanceId));
   }
diff --git a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
index 53de75c..305774d 100644
--- a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
+++ b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/ServiceCenterRegistration.java
@@ -20,6 +20,7 @@ package org.apache.servicecomb.serviceregistry;
 import java.util.Collection;
 
 import org.apache.servicecomb.foundation.common.concurrency.SuppressedRunnableWrapper;
+import org.apache.servicecomb.serviceregistry.api.Registration;
 import org.apache.servicecomb.serviceregistry.api.registry.BasePath;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
diff --git a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
index 1201907..752b255 100644
--- a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
+++ b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/http/ServiceRegistryClientImpl.java
@@ -264,6 +264,7 @@ public final class ServiceRegistryClientImpl implements ServiceRegistryClient {
                 case 200:
                   mInstances
                       .setInstancesResponse(JsonUtils.readValue(bodyBuffer.getBytes(), FindInstancesResponse.class));
+                  mInstances.setNeedRefresh(true);
                   break;
                 case 400: {
                   @SuppressWarnings("unchecked")
diff --git a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery b/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Discovery
similarity index 100%
rename from service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Discovery
rename to service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Discovery
diff --git a/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration b/service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Registration
similarity index 100%
rename from service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.Registration
rename to service-registry/registry-service-center/src/main/resources/META-INF/services/org.apache.servicecomb.serviceregistry.api.Registration


[servicecomb-java-chassis] 02/03: [SCB-1935]publish service center port to local access

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git

commit 5af49a4a9aceb487c2e8acf83d838c6f4e38dfef
Author: liubao <bi...@qq.com>
AuthorDate: Tue May 26 19:49:10 2020 +0800

    [SCB-1935]publish service center port to local access
---
 demo/docker-run-config-edge/pom.xml  |  4 ++--
 demo/docker-run-config-local/pom.xml | 31 -------------------------------
 demo/docker-run-config/pom.xml       |  4 ++--
 3 files changed, 4 insertions(+), 35 deletions(-)

diff --git a/demo/docker-run-config-edge/pom.xml b/demo/docker-run-config-edge/pom.xml
index dbc8e61..ac7341f 100644
--- a/demo/docker-run-config-edge/pom.xml
+++ b/demo/docker-run-config-edge/pom.xml
@@ -52,7 +52,7 @@
                     <time>60000</time>
                   </wait>
                   <ports>
-                    <port>service.center.port:30100</port>
+                    <port>30100:30100</port>
                   </ports>
                 </run>
               </image>
@@ -284,7 +284,7 @@
             <version>2.19.1</version>
             <configuration>
               <systemPropertyVariables>
-                <servicecomb.service.registry.address>http://${docker.hostname}:${service.center.port}</servicecomb.service.registry.address>
+                <servicecomb.service.registry.address>http://${docker.hostname}:30100</servicecomb.service.registry.address>
               </systemPropertyVariables>
               <argLine>${jacoco.failsafe.argLine}</argLine>
             </configuration>
diff --git a/demo/docker-run-config-local/pom.xml b/demo/docker-run-config-local/pom.xml
index 619c5c0..e2a99dd 100644
--- a/demo/docker-run-config-local/pom.xml
+++ b/demo/docker-run-config-local/pom.xml
@@ -39,24 +39,6 @@
           <configuration>
             <images>
               <image>
-                <name>servicecomb/service-center</name>
-                <alias>service-center</alias>
-                <run>
-                  <wait>
-                    <log>server is ready</log>
-                    <tcp>
-                      <ports>
-                        <port>30100</port>
-                      </ports>
-                    </tcp>
-                    <time>60000</time>
-                  </wait>
-                  <ports>
-                    <port>service.center.port:30100</port>
-                  </ports>
-                </run>
-              </image>
-              <image>
                 <name>${demo.service.name}:${project.version}</name>
                 <alias>${demo.service.name}</alias>
                 <run>
@@ -66,17 +48,8 @@
                     </JAVA_OPTS>
                     <JAR_PATH>/maven/maven/${demo.service.name}-${project.version}.jar</JAR_PATH>
                   </env>
-                  <links>
-                    <link>service-center:sc.servicecomb.io</link>
-                  </links>
                   <wait>
                     <log>Register microservice instance success</log>
-                    <!--
-                        the log waiting of the plugin has a bug and fails frequently
-                        refer to https://github.com/fabric8io/docker-maven-plugin/issues/767
-                        this http checking is used as a temporary solution
-                    -->
-
                     <tcp>
                       <ports>
                         <port>8080</port>
@@ -85,12 +58,8 @@
                     <time>120000</time>
                   </wait>
                   <ports>
-                    <port>7070:7070</port>
                     <port>8080:8080</port>
                   </ports>
-                  <dependsOn>
-                    <container>service-center</container>
-                  </dependsOn>
                 </run>
               </image>
             </images>
diff --git a/demo/docker-run-config/pom.xml b/demo/docker-run-config/pom.xml
index ea4445f..b8afd41 100644
--- a/demo/docker-run-config/pom.xml
+++ b/demo/docker-run-config/pom.xml
@@ -52,7 +52,7 @@
                     <time>60000</time>
                   </wait>
                   <ports>
-                    <port>service.center.port:30100</port>
+                    <port>30100:30100</port>
                   </ports>
                 </run>
               </image>
@@ -146,7 +146,7 @@
             <version>2.19.1</version>
             <configuration>
               <systemPropertyVariables>
-                <servicecomb.service.registry.address>http://${docker.hostname}:${service.center.port}</servicecomb.service.registry.address>
+                <servicecomb.service.registry.address>http://${docker.hostname}:30100</servicecomb.service.registry.address>
               </systemPropertyVariables>
               <argLine>${jacoco.failsafe.argLine}</argLine>
             </configuration>


[servicecomb-java-chassis] 03/03: [SCB-1935]reorganize test case

Posted by li...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git

commit 4cc3834b0bc2e38493740022c61b1f420a10d737
Author: liubao <bi...@qq.com>
AuthorDate: Tue May 26 21:20:38 2020 +0800

    [SCB-1935]reorganize test case
---
 .../servicecomb/demo/registry/Application.java     | 26 ++---------
 .../registry/MultiRegistriesServerTestCase.java    | 48 ++++++++++++++++++++
 ...Application.java => ServiceCenterTestCase.java} | 51 ++++++++++------------
 .../servicecomb/demo/CategorizedTestCase.java      |  4 ++
 .../demo/CategorizedTestCaseRunner.java            |  8 +++-
 5 files changed, 84 insertions(+), 53 deletions(-)

diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
index 2ef836c..ffe3756 100644
--- a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
@@ -17,25 +17,18 @@
 
 package org.apache.servicecomb.demo.registry;
 
-import java.util.List;
-import java.util.Map;
-
+import org.apache.servicecomb.demo.CategorizedTestCaseRunner;
 import org.apache.servicecomb.demo.TestMgr;
-import org.apache.servicecomb.provider.pojo.RpcReference;
-import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
 import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
 import org.springframework.boot.WebApplicationType;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.builder.SpringApplicationBuilder;
 import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
 
 @SpringBootApplication
 @EnableServiceComb
 @Component
 public class Application {
-  @RpcReference(microserviceName = "thirdParty-service-center", schemaId = "ServiceCenterEndpoint")
-  static IServiceCenterEndpoint serviceCenterEndpoint;
 
   public static void main(final String[] args) throws Exception {
     new SpringApplicationBuilder().sources(Application.class).web(WebApplicationType.SERVLET).build().run(args);
@@ -43,22 +36,9 @@ public class Application {
     runTest();
   }
 
-  public static void runTest() {
-    RestTemplate template = RestTemplateBuilder.create();
-
-    // invoke demo-multi-registries-server
-    TestMgr.check("2", template
-        .getForObject("cse://demo-multi-registries-server/register/url/prefix/getName?name=2",
-            String.class));
+  public static void runTest() throws Exception {
+    CategorizedTestCaseRunner.runCategorizedTestCase("demo-multi-registries-server");
 
-    // invoke service-center(3rd-parties)
-    @SuppressWarnings("unchecked")
-    Map<String, List<?>> result = (Map<String, List<?>>) serviceCenterEndpoint.getInstances("demo-multi-registries",
-        "demo-multi-registries-server",
-        "true",
-        "0.0.2",
-        "default");
-    TestMgr.check(result.get("instances").size(), 1);
     TestMgr.summary();
     if (!TestMgr.errors().isEmpty()) {
       throw new IllegalStateException("tests failed");
diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/MultiRegistriesServerTestCase.java b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/MultiRegistriesServerTestCase.java
new file mode 100644
index 0000000..d09babf
--- /dev/null
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/MultiRegistriesServerTestCase.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.demo.registry;
+
+import org.apache.servicecomb.demo.CategorizedTestCase;
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
+import org.springframework.stereotype.Component;
+import org.springframework.web.client.RestTemplate;
+
+@Component
+public class MultiRegistriesServerTestCase implements CategorizedTestCase {
+  RestTemplate template = RestTemplateBuilder.create();
+
+  @Override
+  public void testRestTransport() throws Exception {
+
+    // invoke demo-multi-registries-server
+    TestMgr.check("2", template
+        .getForObject("cse://demo-multi-registries-server/register/url/prefix/getName?name=2",
+            String.class));
+  }
+
+  @Override
+  public void testHighwayTransport() throws Exception {
+
+  }
+
+  @Override
+  public void testAllTransport() throws Exception {
+
+  }
+}
diff --git a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterTestCase.java
similarity index 55%
copy from demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
copy to demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterTestCase.java
index 2ef836c..c84bdc2 100644
--- a/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/Application.java
+++ b/demo/demo-multi-registries/demo-multi-registries-client/src/main/java/org/apache/servicecomb/demo/registry/ServiceCenterTestCase.java
@@ -20,48 +20,41 @@ package org.apache.servicecomb.demo.registry;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.servicecomb.demo.CategorizedTestCase;
 import org.apache.servicecomb.demo.TestMgr;
 import org.apache.servicecomb.provider.pojo.RpcReference;
-import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder;
-import org.apache.servicecomb.springboot2.starter.EnableServiceComb;
-import org.springframework.boot.WebApplicationType;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.boot.builder.SpringApplicationBuilder;
 import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
 
-@SpringBootApplication
-@EnableServiceComb
 @Component
-public class Application {
+public class ServiceCenterTestCase implements CategorizedTestCase {
   @RpcReference(microserviceName = "thirdParty-service-center", schemaId = "ServiceCenterEndpoint")
-  static IServiceCenterEndpoint serviceCenterEndpoint;
-
-  public static void main(final String[] args) throws Exception {
-    new SpringApplicationBuilder().sources(Application.class).web(WebApplicationType.SERVLET).build().run(args);
-
-    runTest();
-  }
-
-  public static void runTest() {
-    RestTemplate template = RestTemplateBuilder.create();
-
-    // invoke demo-multi-registries-server
-    TestMgr.check("2", template
-        .getForObject("cse://demo-multi-registries-server/register/url/prefix/getName?name=2",
-            String.class));
+  IServiceCenterEndpoint serviceCenterEndpoint;
 
+  @Override
+  public void testRestTransport() throws Exception {
     // invoke service-center(3rd-parties)
     @SuppressWarnings("unchecked")
-    Map<String, List<?>> result = (Map<String, List<?>>) serviceCenterEndpoint.getInstances("demo-multi-registries",
+    Map<String, List<?>> result = (Map<String, List<?>>) serviceCenterEndpoint.getInstances(
+        "demo-multi-registries",
         "demo-multi-registries-server",
         "true",
         "0.0.2",
         "default");
     TestMgr.check(result.get("instances").size(), 1);
-    TestMgr.summary();
-    if (!TestMgr.errors().isEmpty()) {
-      throw new IllegalStateException("tests failed");
-    }
+  }
+
+  @Override
+  public void testHighwayTransport() throws Exception {
+
+  }
+
+  @Override
+  public void testAllTransport() throws Exception {
+
+  }
+
+  @Override
+  public String getMicroserviceName() {
+    return "thirdParty-service-center";
   }
 }
diff --git a/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CategorizedTestCase.java b/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CategorizedTestCase.java
index 51c733a..dd144ed 100644
--- a/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CategorizedTestCase.java
+++ b/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CategorizedTestCase.java
@@ -32,4 +32,8 @@ public interface CategorizedTestCase {
    * test case which successful in both REST and HIGHWAY transport
    */
   void testAllTransport() throws Exception;
+
+  default String getMicroserviceName() {
+    return null;
+  }
 }
diff --git a/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CategorizedTestCaseRunner.java b/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CategorizedTestCaseRunner.java
index ee508cd..20424df 100644
--- a/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CategorizedTestCaseRunner.java
+++ b/demo/demo-schema/src/main/java/org/apache/servicecomb/demo/CategorizedTestCaseRunner.java
@@ -26,8 +26,14 @@ public class CategorizedTestCaseRunner {
   public static void runCategorizedTestCase(String microserviceName) throws Exception {
     Map<String, CategorizedTestCase> tests = BeanUtils.getContext().getBeansOfType(CategorizedTestCase.class);
     for (String transport : DemoConst.transports) {
-      changeTransport(microserviceName, transport);
       for (CategorizedTestCase testCase : tests.values()) {
+
+        if (testCase.getMicroserviceName() != null) {
+          changeTransport(testCase.getMicroserviceName(), transport);
+        } else {
+          changeTransport(microserviceName, transport);
+        }
+
         testCase.testAllTransport();
         if ("rest".equals(transport)) {
           testCase.testRestTransport();