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 2019/09/06 13:32:59 UTC
[dubbo] 01/04: add service discovery related samples
This is an automated email from the ASF dual-hosted git repository.
liujun pushed a commit to branch cloud-native
in repository https://gitbox.apache.org/repos/asf/dubbo.git
commit 1ade69248c0a6ab83053e4751142a495cfcd35e2
Author: ken.lj <ke...@gmail.com>
AuthorDate: Wed Aug 28 17:24:06 2019 +0800
add service discovery related samples
---
.../samples/microservices/sc/Application.java | 56 ---------------
.../provider/src/main/resources/bootstrap.yml | 24 -------
dubbo-demo/dubbo-call-sc/consumer/pom.xml | 81 ----------------------
.../samples/microservices/sc/Application.java | 55 ---------------
.../dubbo-sc-consumer}/pom.xml | 12 +++-
.../apache/dubbo/demo/consumer/Application.java | 9 +--
.../dubbo/samples/microservices/sc/rest/User.java | 4 --
.../samples/microservices/sc/rest/UserService.java | 0
.../microservices/sc/rest/UserServiceImpl.java | 0
.../src/main/resources/dubbo.properties | 0
.../src/main/resources/log4j.properties | 0
.../src/main/resources/spring/dubbo-consumer.xml | 9 ++-
.../{provider => dubbo-sc-provider}/pom.xml | 2 +-
.../samples/microservices/sc/Application.java | 0
.../configuration/RestTemplateConfiguration.java | 0
.../microservices/sc/controller/MeController.java | 0
.../sc/controller/PropertyController.java | 0
.../sc/controller/TestController.java | 1 +
.../samples/microservices/sc/controller/User.java | 0
.../samples/microservices/sc/feign/TestFeign.java | 0
.../src/main/resources/application.yml | 0
.../src/main/resources/bootstrap.yml | 3 +
dubbo-demo/dubbo-call-sc/pom.xml | 4 +-
.../README.md | 0
.../dubbo-scdubbo-consumer}/pom.xml | 16 ++++-
.../apache/dubbo/demo/consumer/Application.java | 7 ++
.../dubbo/samples/microservices/sc/rest/User.java | 4 --
.../samples/microservices/sc/rest/UserService.java | 0
.../microservices/sc/rest/UserServiceImpl.java | 0
.../src/main/resources/dubbo.properties | 0
.../src/main/resources/log4j.properties | 0
.../src/main/resources/spring/dubbo-consumer.xml} | 17 +++--
.../dubbo-scdubbo-provider}/pom.xml | 4 +-
.../samples/microservices/sc/Application.java | 0
.../configuration/RestTemplateConfiguration.java | 0
.../microservices/sc/controller/MeController.java | 0
.../sc/controller/PropertyController.java | 0
.../sc/controller/TestController.java | 9 ++-
.../samples/microservices/sc/controller/User.java | 0
.../samples/microservices/sc/feign/TestFeign.java | 0
.../src/main/resources/application.yml | 0
.../src/main/resources/bootstrap.yml | 26 +++++++
.../dubbo-scdubbo-provider2}/pom.xml | 25 +++++--
.../apache/dubbo/demo/provider}/Application.java | 12 ++--
.../dubbo/demo/provider/DemoServiceImpl.java | 0
.../src/main/resources/dubbo.properties | 1 +
.../src/main/resources/log4j.properties | 0
.../src/main/resources/spring/dubbo-provider.xml | 4 +-
.../pom.xml | 7 +-
.../src/main/resources/spring/dubbo-consumer.xml | 2 +-
.../src/main/resources/spring/dubbo-provider.xml | 2 +-
dubbo-demo/pom.xml | 8 +--
.../com/bettercloud/spring/cloud/Application.java | 15 ----
.../configuration/RestTemplateConfiguration.java | 17 -----
.../spring/cloud/controller/ClientController.java | 29 --------
.../src/main/resources/application-holding.yml | 3 -
.../consumer/src/main/resources/application.yml | 7 --
.../consumer/src/main/resources/bootstrap.yml | 26 -------
dubbo-demo/sc-call-dubbo/pom.xml | 6 +-
.../{consumer => sc-dubbo-consumer}/pom.xml | 5 +-
.../samples/microservices/sc/Application.java | 0
.../configuration/RestTemplateConfiguration.java | 0
.../microservices/sc/controller/MeController.java | 0
.../sc/controller/PropertyController.java | 8 +--
.../sc/controller/TestController.java | 21 ++----
.../samples/microservices/sc/controller/User.java | 0
.../samples/microservices/sc}/feign/TestFeign.java | 7 +-
.../src/main/resources/application.yml | 0
.../src/main/resources/bootstrap.yml | 26 +++++++
.../sc-dubbo-provider}/pom.xml | 60 ++++++++++++----
.../apache/dubbo/demo/provider/Application.java | 25 +++++--
.../org/apache/dubbo/demo/provider}/rest/User.java | 6 +-
.../dubbo/demo/provider}/rest/UserService.java | 2 +-
.../dubbo/demo/provider}/rest/UserServiceImpl.java | 2 +-
.../src/main/resources/log4j.properties | 0
.../provider => servicediscovery-transfer}/pom.xml | 33 ++++++++-
.../pom.xml | 2 +-
.../apache/dubbo/demo/consumer/Application.java | 3 +
.../src/main/resources/dubbo.properties | 0
.../src/main/resources/log4j.properties | 0
.../src/main/resources/spring/dubbo-consumer.xml | 5 +-
.../pom.xml | 2 +-
.../apache/dubbo/demo/consumer/Application.java | 6 +-
.../src/main/resources/dubbo.properties | 0
.../src/main/resources/log4j.properties | 0
.../src/main/resources/spring/dubbo-consumer.xml | 6 +-
.../pom.xml | 23 ++++--
.../apache/dubbo/demo/provider}/Application.java | 12 ++--
.../dubbo/demo/provider/DemoServiceImpl.java | 0
.../dubbo/demo/provider/GreetingServiceImpl.java | 0
.../src/main/resources/dubbo.properties | 1 +
.../src/main/resources/log4j.properties | 0
.../src/main/resources/spring/dubbo-provider.xml | 11 ++-
93 files changed, 321 insertions(+), 452 deletions(-)
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java b/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
deleted file mode 100644
index 4164f60..0000000
--- a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
+++ /dev/null
@@ -1,56 +0,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.
- */
-package org.apache.dubbo.samples.microservices.sc;
-
-import org.apache.dubbo.bootstrap.DubboBootstrap;
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.config.ReferenceConfig;
-import org.apache.dubbo.config.RegistryConfig;
-import org.apache.dubbo.config.context.ConfigManager;
-import org.apache.dubbo.samples.microservices.sc.rest.UserService;
-
-public class Application {
- public static void main(String[] args) {
- RegistryConfig interfaceRegistry = new RegistryConfig();
- interfaceRegistry.setId("interfaceRegistry");
- interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181");
-
- new DubboBootstrap()
- .application("dubbo-consumer-demo")
- // Zookeeper
- .registry(interfaceRegistry)
- // Nacos
-// .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo"))
- .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
- .onlyRegisterProvider(true)
- .start()
- .await();
-
- ConfigManager configManager = ConfigManager.getInstance();
-
- ReferenceConfig<UserService> referenceConfig1 = configManager.getReferenceConfig("user");
- UserService userService = referenceConfig1.get();
-
- for (int i = 0; i < 500; i++) {
- Thread.sleep(2000L);
- System.out.println(echoService.echo("Hello,World"));
- System.out.println(userService.getUser(1L));
- }
- }
-}
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/resources/bootstrap.yml b/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/resources/bootstrap.yml
deleted file mode 100644
index cabb49f..0000000
--- a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/resources/bootstrap.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-server:
- port: 8099
-
-spring:
- application:
- name: spring-cloud-provider-for-dubbo
- cloud:
- consul:
- host: localhost
- port: 8500
- enabled: true
- discovery:
- instance-id: ${spring.application.name}:${random.value}
- service-name: ${spring.application.name}
- config:
- format: yaml
- prefix: config
- defaultContext: application
- data-key: data
- profileSeparator: '-'
-
-management:
- security:
- enabled: false
\ No newline at end of file
diff --git a/dubbo-demo/dubbo-call-sc/consumer/pom.xml b/dubbo-demo/dubbo-call-sc/consumer/pom.xml
deleted file mode 100644
index f1d9dfd..0000000
--- a/dubbo-demo/dubbo-call-sc/consumer/pom.xml
+++ /dev/null
@@ -1,81 +0,0 @@
-<?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">
- <parent>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-call-sc</artifactId>
- <version>${revision}</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>consumer</artifactId>
-
- <properties>
- <skip_maven_deploy>true</skip_maven_deploy>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-config-api</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-demo-interface</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-multicast</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-dubbo</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-netty4</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-hessian2</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-bootstrap</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-consul</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-rest</artifactId>
- <version>${project.parent.version}</version>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java b/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
deleted file mode 100644
index 3a017a2..0000000
--- a/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
+++ /dev/null
@@ -1,55 +0,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.
- */
-package org.apache.dubbo.samples.microservices.sc;
-
-import org.apache.dubbo.bootstrap.DubboBootstrap;
-import org.apache.dubbo.config.ReferenceConfig;
-import org.apache.dubbo.config.RegistryConfig;
-import org.apache.dubbo.config.context.ConfigManager;
-import org.apache.dubbo.samples.microservices.sc.rest.UserService;
-
-public class Application {
- public static void main(String[] args) throws Exception{
- RegistryConfig interfaceRegistry = new RegistryConfig();
- interfaceRegistry.setId("interfaceRegistry");
- interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181?" +
- "registry.type=service&subscribed.services=spring-cloud-provider-for-dubbo");
-
- new DubboBootstrap()
- .application("dubbo-consumer-demo")
- // Zookeeper
- .registry(interfaceRegistry)
- // Nacos
-// .registry("consul", builder -> builder.address("consul://127.0.0.1:8500?registry.type=service&subscribed.services=dubbo-provider-demo"))
- .reference("user", builder -> builder.interfaceClass(UserService.class).protocol("rest"))
- .onlyRegisterProvider(true)
- .start()
- .await();
-
- ConfigManager configManager = ConfigManager.getInstance();
-
- ReferenceConfig<UserService> referenceConfig1 = configManager.getReferenceConfig("user");
- UserService userService = referenceConfig1.get();
-
- for (int i = 0; i < 500; i++) {
- Thread.sleep(2000L);
- System.out.println(userService.getUser(1L));
- }
- }
-}
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/pom.xml
similarity index 89%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/pom.xml
index dcf6e28..3c8e87f 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
+++ b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/pom.xml
@@ -19,11 +19,11 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.dubbo</groupId>
- <artifactId>servicediscovery-transfer</artifactId>
+ <artifactId>dubbo-call-sc</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>servicediscovery-consumer</artifactId>
+ <artifactId>dubbo-sc-consumer</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>The demo consumer module of dubbo project</description>
@@ -74,11 +74,19 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-rpc-rest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-netty4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-hessian2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-registry-consul</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
similarity index 78%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
index f448a18..0bfd8a2 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
+++ b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
@@ -16,7 +16,8 @@
*/
package org.apache.dubbo.demo.consumer;
-import org.apache.dubbo.demo.DemoService;
+import org.apache.dubbo.samples.microservices.sc.rest.User;
+import org.apache.dubbo.samples.microservices.sc.rest.UserService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -24,8 +25,8 @@ public class Application {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
context.start();
- DemoService demoService = context.getBean("demoService", DemoService.class);
- String hello = demoService.sayHello("world");
- System.out.println("result: " + hello);
+ UserService userService = context.getBean("userService", UserService.class);
+ User user = userService.getUser(1L);
+ System.out.println("result: " + user);
}
}
diff --git a/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
similarity index 92%
copy from dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
index c365f8f..6387049 100644
--- a/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
+++ b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
@@ -18,14 +18,12 @@
*/
package org.apache.dubbo.samples.microservices.sc.rest;
-import org.codehaus.jackson.annotate.JsonProperty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
@@ -37,8 +35,6 @@ public class User implements Serializable {
@Min(1L)
private Long id;
- @JsonProperty("username")
- @XmlElement(name = "username")
@NotNull
@Size(min = 6, max = 50)
private String name;
diff --git a/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java
rename to dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java
diff --git a/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java
rename to dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/resources/dubbo.properties
similarity index 100%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/resources/dubbo.properties
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/resources/log4j.properties
similarity index 100%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/resources/log4j.properties
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/resources/spring/dubbo-consumer.xml
similarity index 75%
copy from dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/resources/spring/dubbo-consumer.xml
index d3081f6..cfd722d 100644
--- a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
+++ b/dubbo-demo/dubbo-call-sc/dubbo-sc-consumer/src/main/resources/spring/dubbo-consumer.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 name="demo-consumer"/>
+ <dubbo:application name="dubbo-sc-consumer"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+ <dubbo:registry address="consul://127.0.0.1:8500">
+ <dubbo:parameter key="registry-type" value="service"/>
+ </dubbo:registry>
- <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
+ <dubbo:reference provided-by="spring-cloud-provider-for-dubbo" id="userService" check="false" protocol="rest"
+ interface="org.apache.dubbo.samples.microservices.sc.rest.UserService"/>
</beans>
diff --git a/dubbo-demo/dubbo-call-sc/provider/pom.xml b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/pom.xml
similarity index 98%
rename from dubbo-demo/dubbo-call-sc/provider/pom.xml
rename to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/pom.xml
index f3a3ea0..d9d1d66 100644
--- a/dubbo-demo/dubbo-call-sc/provider/pom.xml
+++ b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/pom.xml
@@ -28,7 +28,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>provider</artifactId>
+ <artifactId>dubbo-sc-provider</artifactId>
<dependencyManagement>
<dependencies>
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
similarity index 100%
copy from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
similarity index 100%
copy from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
similarity index 100%
copy from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
rename to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
similarity index 99%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
rename to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
index 96801f8..ade2917 100644
--- a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
+++ b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
@@ -1,6 +1,7 @@
package org.apache.dubbo.samples.microservices.sc.controller;
import org.apache.dubbo.samples.microservices.sc.feign.TestFeign;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
similarity index 100%
copy from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
rename to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/resources/application.yml b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/resources/application.yml
similarity index 100%
copy from dubbo-demo/dubbo-call-sc/provider/src/main/resources/application.yml
copy to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/resources/application.yml
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/resources/bootstrap.yml b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/resources/bootstrap.yml
similarity index 82%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/resources/bootstrap.yml
rename to dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/resources/bootstrap.yml
index cabb49f..2829237 100644
--- a/dubbo-demo/dubbo-call-sc/provider/src/main/resources/bootstrap.yml
+++ b/dubbo-demo/dubbo-call-sc/dubbo-sc-provider/src/main/resources/bootstrap.yml
@@ -12,6 +12,9 @@ spring:
discovery:
instance-id: ${spring.application.name}:${random.value}
service-name: ${spring.application.name}
+ heartbeat:
+ enabled: false
+ health-check-interval: 1000s
config:
format: yaml
prefix: config
diff --git a/dubbo-demo/dubbo-call-sc/pom.xml b/dubbo-demo/dubbo-call-sc/pom.xml
index 46625c4..23bd275 100644
--- a/dubbo-demo/dubbo-call-sc/pom.xml
+++ b/dubbo-demo/dubbo-call-sc/pom.xml
@@ -30,8 +30,8 @@
<packaging>pom</packaging>
<modules>
- <module>provider</module>
- <module>consumer</module>
+ <module>dubbo-sc-provider</module>
+ <module>dubbo-sc-consumer</module>
</modules>
<properties>
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/README.md b/dubbo-demo/dubbo-call-scdubbo/README.md
similarity index 100%
rename from dubbo-demo/dubbo-call-sc&dubbo/README.md
rename to dubbo-demo/dubbo-call-scdubbo/README.md
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/pom.xml
similarity index 85%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/pom.xml
index dcf6e28..6e06da3 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/pom.xml
@@ -19,11 +19,11 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.dubbo</groupId>
- <artifactId>servicediscovery-transfer</artifactId>
+ <artifactId>dubbo-call-scdubbo</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>servicediscovery-consumer</artifactId>
+ <artifactId>dubbo-scdubbo-consumer</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>The demo consumer module of dubbo project</description>
@@ -62,6 +62,10 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-configcenter-consul</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-metadata-report-nacos</artifactId>
</dependency>
<dependency>
@@ -74,11 +78,19 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-rpc-rest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-remoting-netty4</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-hessian2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-registry-consul</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
similarity index 81%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
index f448a18..5b2d932 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
@@ -17,6 +17,8 @@
package org.apache.dubbo.demo.consumer;
import org.apache.dubbo.demo.DemoService;
+import org.apache.dubbo.samples.microservices.sc.rest.User;
+import org.apache.dubbo.samples.microservices.sc.rest.UserService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -24,6 +26,11 @@ public class Application {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
context.start();
+
+ UserService userService = context.getBean("userService", UserService.class);
+ User user = userService.getUser(1L);
+ System.out.println("result: " + user);
+
DemoService demoService = context.getBean("demoService", DemoService.class);
String hello = demoService.sayHello("world");
System.out.println("result: " + hello);
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
similarity index 92%
rename from dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
rename to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
index c365f8f..6387049 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
@@ -18,14 +18,12 @@
*/
package org.apache.dubbo.samples.microservices.sc.rest;
-import org.codehaus.jackson.annotate.JsonProperty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
@@ -37,8 +35,6 @@ public class User implements Serializable {
@Min(1L)
private Long id;
- @JsonProperty("username")
- @XmlElement(name = "username")
@NotNull
@Size(min = 6, max = 50)
private String name;
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java
similarity index 100%
copy from dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java
similarity index 100%
copy from dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/resources/dubbo.properties
similarity index 100%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/resources/dubbo.properties
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/resources/log4j.properties
similarity index 100%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/resources/log4j.properties
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/resources/spring/dubbo-consumer.xml
similarity index 63%
copy from dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/resources/spring/dubbo-consumer.xml
index 1eaf379..c93add5 100644
--- a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-consumer/src/main/resources/spring/dubbo-consumer.xml
@@ -21,14 +21,19 @@
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-provider"/>
+ <dubbo:application name="dubbo-sc-consumer"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+ <!-- consumes Native Dubbo service -->
+ <dubbo:registry id="dubbo" address="zookeeper://127.0.0.1:2181?registry-type=service"/>
+ <dubbo:reference registry="dubbo" id="demoService" check="false"
+ interface="org.apache.dubbo.demo.DemoService"/>
- <dubbo:protocol name="dubbo"/>
+ <!-- consumes Spring Cloud service-->
+ <dubbo:registry id="sc" address="consul://127.0.0.1:8500">
+ <dubbo:parameter key="registry-type" value="service"/>
+ </dubbo:registry>
+ <dubbo:reference registry="sc" provided-by="scdubbo-provider" id="userService" check="false" protocol="rest"
+ interface="org.apache.dubbo.samples.microservices.sc.rest.UserService"/>
- <bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
-
- <dubbo:service interface="org.apache.dubbo.demo.DemoService" ref="demoService"/>
</beans>
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/pom.xml b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/pom.xml
similarity index 96%
rename from dubbo-demo/dubbo-call-sc&dubbo/provider/pom.xml
rename to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/pom.xml
index f3a3ea0..91b6738 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/provider/pom.xml
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/pom.xml
@@ -22,13 +22,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-call-sc</artifactId>
+ <artifactId>dubbo-call-scdubbo</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>provider</artifactId>
+ <artifactId>dubbo-scdubbo-provider</artifactId>
<dependencyManagement>
<dependencies>
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
rename to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
rename to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
rename to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
similarity index 100%
copy from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
similarity index 85%
copy from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
index 615e998..c21c007 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
@@ -1,13 +1,15 @@
package org.apache.dubbo.samples.microservices.sc.controller;
import org.apache.dubbo.samples.microservices.sc.feign.TestFeign;
+
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
-@RequestMapping("/ping")
+@RequestMapping("/users")
public class TestController {
@Value("${spring.application.name}")
@@ -22,6 +24,11 @@ public class TestController {
this.testFeign = testFeign;
}
+ @RequestMapping("{id}")
+ public User getUser(@PathVariable("id") Long id) {
+ return new User(id, "username-" + id);
+ }
+
@RequestMapping
public String doAlive() {
return "Alive!";
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
similarity index 100%
copy from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
rename to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/resources/application.yml b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/resources/application.yml
similarity index 100%
rename from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/resources/application.yml
rename to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/resources/application.yml
diff --git a/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/resources/bootstrap.yml b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..d6bad3c
--- /dev/null
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider/src/main/resources/bootstrap.yml
@@ -0,0 +1,26 @@
+server:
+ port: 8099
+
+spring:
+ application:
+ name: scdubbo-provider
+ cloud:
+ consul:
+ host: localhost
+ port: 8500
+ enabled: true
+
+management:
+ security:
+ enabled: false
+
+ endpoint:
+ consul:
+ enabled: false
+ health:
+ consul:
+ enabled: false
+
+endpoints:
+ consul:
+ enabled: false
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/pom.xml
similarity index 82%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/pom.xml
index dcf6e28..34845d5 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/pom.xml
@@ -19,17 +19,19 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.dubbo</groupId>
- <artifactId>servicediscovery-transfer</artifactId>
+ <artifactId>dubbo-call-scdubbo</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>servicediscovery-consumer</artifactId>
+ <artifactId>dubbo-scdubbo-provider2</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
- <description>The demo consumer module of dubbo project</description>
+ <description>The demo provider module of dubbo project</description>
<properties>
<skip_maven_deploy>true</skip_maven_deploy>
+ <slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
</properties>
+
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
@@ -66,11 +68,11 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-config-spring</artifactId>
+ <artifactId>dubbo-rpc-dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-dubbo</artifactId>
+ <artifactId>dubbo-config-spring</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
@@ -80,5 +82,18 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-hessian2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-log4j12.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/java/org/apache/dubbo/demo/provider/Application.java
similarity index 73%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/java/org/apache/dubbo/demo/provider/Application.java
index f448a18..d1ab5be 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/java/org/apache/dubbo/demo/provider/Application.java
@@ -14,18 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.demo.consumer;
-
-import org.apache.dubbo.demo.DemoService;
+package org.apache.dubbo.demo.provider;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Application {
- public static void main(String[] args) {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
+ public static void main(String[] args) throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-provider.xml");
context.start();
- DemoService demoService = context.getBean("demoService", DemoService.class);
- String hello = demoService.sayHello("world");
- System.out.println("result: " + hello);
+ System.in.read();
}
}
diff --git a/dubbo-demo/sc-call-dubbo/provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
similarity index 100%
copy from dubbo-demo/sc-call-dubbo/provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
diff --git a/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/resources/dubbo.properties b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/resources/dubbo.properties
new file mode 100644
index 0000000..ad602ba
--- /dev/null
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/resources/dubbo.properties
@@ -0,0 +1 @@
+dubbo.application.qos.port=22222
diff --git a/dubbo-demo/sc-call-dubbo/provider/src/main/resources/log4j.properties b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/resources/log4j.properties
similarity index 100%
rename from dubbo-demo/sc-call-dubbo/provider/src/main/resources/log4j.properties
rename to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/resources/log4j.properties
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/resources/spring/dubbo-provider.xml
similarity index 95%
copy from dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
copy to dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/resources/spring/dubbo-provider.xml
index 1eaf379..7b4cd15 100644
--- a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
+++ b/dubbo-demo/dubbo-call-scdubbo/dubbo-scdubbo-provider2/src/main/resources/spring/dubbo-provider.xml
@@ -21,9 +21,9 @@
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-provider"/>
+ <dubbo:application name="scdubbo-provider2"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+ <dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service"/>
<dubbo:protocol name="dubbo"/>
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/pom.xml b/dubbo-demo/dubbo-call-scdubbo/pom.xml
similarity index 91%
rename from dubbo-demo/dubbo-call-sc&dubbo/pom.xml
rename to dubbo-demo/dubbo-call-scdubbo/pom.xml
index 46625c4..2b7e079 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/pom.xml
+++ b/dubbo-demo/dubbo-call-scdubbo/pom.xml
@@ -30,8 +30,9 @@
<packaging>pom</packaging>
<modules>
- <module>provider</module>
- <module>consumer</module>
+ <module>dubbo-scdubbo-provider</module>
+ <module>dubbo-scdubbo-provider2</module>
+ <module>dubbo-scdubbo-consumer</module>
</modules>
<properties>
@@ -39,7 +40,7 @@
<spring-boot-maven-plugin.version>2.1.4.RELEASE</spring-boot-maven-plugin.version>
</properties>
- <artifactId>dubbo-call-sc</artifactId>
+ <artifactId>dubbo-call-scdubbo</artifactId>
<build>
<plugins>
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
index d3081f6..892392a 100644
--- a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
@@ -23,7 +23,7 @@
<dubbo:application name="demo-consumer"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+ <dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service"/>
<dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
index 1eaf379..fce0c7f 100644
--- a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
+++ b/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
@@ -23,7 +23,7 @@
<dubbo:application name="demo-provider"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+ <dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service"/>
<dubbo:protocol name="dubbo"/>
diff --git a/dubbo-demo/pom.xml b/dubbo-demo/pom.xml
index a4dae32..2b4959c 100644
--- a/dubbo-demo/pom.xml
+++ b/dubbo-demo/pom.xml
@@ -36,10 +36,10 @@
<module>dubbo-demo-annotation</module>
<module>dubbo-demo-api</module>
<module>dubbo-demo-servicediscovery-xml</module>
- <!-- <module>servicediscovery-transfer</module>-->
- <!-- <module>dubbo-call-sc</module>-->
- <!-- <module>dubbo-call-sc&dubbo</module>-->
- <!-- <module>sc-call-dubbo</module>-->
+ <module>servicediscovery-transfer</module>
+ <module>dubbo-call-sc</module>
+ <module>dubbo-call-scdubbo</module>
+ <module>sc-call-dubbo</module>
</modules>
<dependencyManagement>
diff --git a/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/Application.java b/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/Application.java
deleted file mode 100644
index e1f07cb..0000000
--- a/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/Application.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.bettercloud.spring.cloud;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.cloud.netflix.feign.EnableFeignClients;
-
-@SpringBootApplication
-@EnableDiscoveryClient
-@EnableFeignClients
-public class Application {
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-}
\ No newline at end of file
diff --git a/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/configuration/RestTemplateConfiguration.java b/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/configuration/RestTemplateConfiguration.java
deleted file mode 100644
index cf0a2b1..0000000
--- a/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/configuration/RestTemplateConfiguration.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.bettercloud.spring.cloud.configuration;
-
-import org.springframework.cloud.client.loadbalancer.LoadBalanced;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.client.RestTemplate;
-
-@Configuration
-public class RestTemplateConfiguration {
-
- @Bean
- @LoadBalanced
- RestTemplate loadBalancedRestTemplate() {
- return new RestTemplate();
- }
-
-}
diff --git a/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/controller/ClientController.java b/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/controller/ClientController.java
deleted file mode 100644
index b38edf3..0000000
--- a/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/controller/ClientController.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.bettercloud.spring.cloud.controller;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.client.RestTemplate;
-
-
-@RestController
-@RequestMapping("/client")
-public class ClientController {
-
- private String serviceEndpoint;
- private RestTemplate restTemplate;
-
- @Autowired
- public ClientController(@Value("${service.me}") final String serviceEndpoint, final RestTemplate restTemplate) {
- this.serviceEndpoint = serviceEndpoint;
- this.restTemplate = restTemplate;
- }
-
- @GetMapping
- public String getService() {
- return restTemplate.getForEntity(serviceEndpoint, String.class).getBody();
- }
-
-}
diff --git a/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/application-holding.yml b/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/application-holding.yml
deleted file mode 100644
index 7a8a421..0000000
--- a/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/application-holding.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-service:
- host: http://service-holding
- me: ${service.host}/me
diff --git a/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/application.yml b/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/application.yml
deleted file mode 100644
index bb7bfea..0000000
--- a/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/application.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-management:
- security:
- enabled: false
-endpoints:
- shutdown:
- enabled: true
-
diff --git a/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/bootstrap.yml b/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/bootstrap.yml
deleted file mode 100644
index 73dacfc..0000000
--- a/dubbo-demo/sc-call-dubbo/consumer/src/main/resources/bootstrap.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-server:
- port: 8080
-
-spring:
- application:
- name: client
- cloud:
- consul:
- host: consul
- port: 8500
- enabled: true
- config:
- format: yaml
- prefix: config
- defaultContext: application
- data-key: data
- profileSeparator: '-'
- vault:
- scheme: http
- host: vault
- authentication: TOKEN
- token: ${VAULT_APP_TOKEN}
-
-management:
- security:
- enabled: false
\ No newline at end of file
diff --git a/dubbo-demo/sc-call-dubbo/pom.xml b/dubbo-demo/sc-call-dubbo/pom.xml
index 46625c4..a21890e 100644
--- a/dubbo-demo/sc-call-dubbo/pom.xml
+++ b/dubbo-demo/sc-call-dubbo/pom.xml
@@ -30,8 +30,8 @@
<packaging>pom</packaging>
<modules>
- <module>provider</module>
- <module>consumer</module>
+ <module>sc-dubbo-provider</module>
+ <module>sc-dubbo-consumer</module>
</modules>
<properties>
@@ -39,7 +39,7 @@
<spring-boot-maven-plugin.version>2.1.4.RELEASE</spring-boot-maven-plugin.version>
</properties>
- <artifactId>dubbo-call-sc</artifactId>
+ <artifactId>sc-call-dubbo</artifactId>
<build>
<plugins>
diff --git a/dubbo-demo/sc-call-dubbo/consumer/pom.xml b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/pom.xml
similarity index 97%
rename from dubbo-demo/sc-call-dubbo/consumer/pom.xml
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/pom.xml
index e938869..1dc5a0e 100644
--- a/dubbo-demo/sc-call-dubbo/consumer/pom.xml
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/pom.xml
@@ -22,14 +22,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-call-sc</artifactId>
+ <artifactId>sc-call-dubbo</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>consumer</artifactId>
-
+ <artifactId>sc-dubbo-consumer</artifactId>
<dependencyManagement>
<dependencies>
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/Application.java
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/configuration/RestTemplateConfiguration.java
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/MeController.java
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
similarity index 88%
rename from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
index cb24179..513df7f 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/PropertyController.java
@@ -28,18 +28,18 @@ public class PropertyController {
@Value("${infrastructurePassword:default value}")
private String infrastructurePassword;
- @Value("${password:mypassword}")
- private String secret;
+ @Value("${password:mypassword}")
+ private String secret;
@RequestMapping
public String getProperty() {
return "<h3>applicationProperty:</h3> " + applicationProperty + "</br>"
- + "<h3>property:</h3> " + property + "</br>"
+ + "<h3>property:</h3> " + property + "</br>"
+ "<h3>property2:</h3> " + property2 + "</br>"
+ "<h3>infrastructureDesc:</h3> " + infrastructureDesc + "</br>"
+ "<h3>infrastructureUserName:</h3> " + infrastructureUserName + "</br>"
+ "<h3>infrastructurePassword:</h3> " + infrastructurePassword + "</br>"
- + "<h3>vault password:</h3>" + secret + "</br>";
+ + "<h3>vault password:</h3>" + secret + "</br>";
}
}
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
similarity index 68%
rename from dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
index 615e998..bfbe620 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/TestController.java
@@ -1,13 +1,14 @@
package org.apache.dubbo.samples.microservices.sc.controller;
import org.apache.dubbo.samples.microservices.sc.feign.TestFeign;
+
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
@RestController
-@RequestMapping("/ping")
+@RequestMapping("/dubbo")
public class TestController {
@Value("${spring.application.name}")
@@ -22,24 +23,14 @@ public class TestController {
this.testFeign = testFeign;
}
- @RequestMapping
- public String doAlive() {
- return "Alive!";
- }
-
- @RequestMapping("/rest")
- public String doRestAlive() {
- return new RestTemplate().getForObject("http://localhost:8099/ping", String.class);
- }
-
- @RequestMapping("/rest/ribbon")
+ @RequestMapping("/rest/user")
public String doRestAliveUsingEurekaAndRibbon() {
- String url = "http://dubbo-provider-demo/users/1";
- System.out.println("url: "+url);
+ String url = "http://dubbo-provider-for-sc/users/1";
+ System.out.println("url: " + url);
return restTemplate.getForObject(url, String.class);
}
- @RequestMapping("/rest/feign")
+ @RequestMapping("/rest/user/feign")
public String doRestAliveUsingFeign() {
return testFeign.doAlive();
}
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/controller/User.java
diff --git a/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/feign/TestFeign.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
similarity index 58%
rename from dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/feign/TestFeign.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
index e8663ec..15abd1f 100644
--- a/dubbo-demo/sc-call-dubbo/consumer/src/main/java/com/bettercloud/spring/cloud/feign/TestFeign.java
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/feign/TestFeign.java
@@ -1,12 +1,13 @@
-package com.bettercloud.spring.cloud.feign;
+package org.apache.dubbo.samples.microservices.sc.feign;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-@FeignClient(name = "springcloudwebtest")
+@FeignClient(name = "dubbo-provider-for-sc")
public interface TestFeign {
- @RequestMapping(value="/ping", method = RequestMethod.GET)
+ @RequestMapping(value = "/users/1", method = RequestMethod.GET)
String doAlive();
+
}
diff --git a/dubbo-demo/dubbo-call-sc/provider/src/main/resources/application.yml b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/resources/application.yml
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/provider/src/main/resources/application.yml
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/resources/application.yml
diff --git a/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/resources/bootstrap.yml b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..d6bad3c
--- /dev/null
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-consumer/src/main/resources/bootstrap.yml
@@ -0,0 +1,26 @@
+server:
+ port: 8099
+
+spring:
+ application:
+ name: scdubbo-provider
+ cloud:
+ consul:
+ host: localhost
+ port: 8500
+ enabled: true
+
+management:
+ security:
+ enabled: false
+
+ endpoint:
+ consul:
+ enabled: false
+ health:
+ consul:
+ enabled: false
+
+endpoints:
+ consul:
+ enabled: false
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/consumer/pom.xml b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/pom.xml
similarity index 64%
rename from dubbo-demo/dubbo-call-sc&dubbo/consumer/pom.xml
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-provider/pom.xml
index f1d9dfd..88f2a73 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/consumer/pom.xml
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/pom.xml
@@ -22,59 +22,89 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-call-sc</artifactId>
+ <artifactId>sc-call-dubbo</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
- <artifactId>consumer</artifactId>
-
<properties>
<skip_maven_deploy>true</skip_maven_deploy>
+ <slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
</properties>
+ <artifactId>sc-dubbo-provider</artifactId>
+
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-config-api</artifactId>
+ <artifactId>dubbo-demo-interface</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-demo-interface</artifactId>
- <version>${project.parent.version}</version>
+ <artifactId>dubbo-registry-multicast</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-multicast</artifactId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-dubbo</artifactId>
+ <artifactId>dubbo-registry-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-remoting-netty4</artifactId>
+ <artifactId>dubbo-registry-consul</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-serialization-hessian2</artifactId>
+ <artifactId>dubbo-configcenter-zookeeper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-bootstrap</artifactId>
- <version>${project.parent.version}</version>
+ <artifactId>dubbo-configcenter-nacos</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-registry-consul</artifactId>
- <version>${project.parent.version}</version>
+ <artifactId>dubbo-metadata-report-nacos</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-rpc-dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-rpc-rest</artifactId>
- <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-config-spring</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-netty4</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-serialization-hessian2</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-log4j12.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
</dependency>
</dependencies>
diff --git a/dubbo-demo/sc-call-dubbo/provider/src/main/java/org/apache/dubbo/demo/provider/Application.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
similarity index 57%
rename from dubbo-demo/sc-call-dubbo/provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
index 5990d75..f1826ce 100644
--- a/dubbo-demo/sc-call-dubbo/provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
@@ -18,19 +18,30 @@
*/
package org.apache.dubbo.demo.provider;
+import org.apache.dubbo.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
-import org.apache.dubbo.demo.DemoService;
+import org.apache.dubbo.demo.provider.rest.UserService;
+import org.apache.dubbo.demo.provider.rest.UserServiceImpl;
public class Application {
public static void main(String[] args) throws Exception {
- ServiceConfig<DemoServiceImpl> service = new ServiceConfig<>();
- service.setApplication(new ApplicationConfig("dubbo-demo-api-provider"));
- service.setRegistry(new RegistryConfig("zookeeper://127.0.0.1:2181"));
- service.setInterface(DemoService.class);
- service.setRef(new DemoServiceImpl());
- service.export();
+ ServiceConfig<UserService> service = new ServiceConfig<>();
+ service.setInterface(UserService.class);
+ service.setRef(new UserServiceImpl());
+
+ ProtocolConfig protocolConfig = new ProtocolConfig("rest");
+ protocolConfig.setPort(8090);
+
+ DubboBootstrap bootstrap = new DubboBootstrap();
+ bootstrap.application(new ApplicationConfig("dubbo-provider-for-sc"))
+ .registry(new RegistryConfig("consul://127.0.0.1:8500?registry-type=service"))
+ .protocol(protocolConfig)
+ .service(service)
+ .start();
+
System.in.read();
}
}
diff --git a/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/User.java
similarity index 89%
rename from dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/User.java
index c365f8f..bf63212 100644
--- a/dubbo-demo/dubbo-call-sc/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/User.java
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/User.java
@@ -16,16 +16,14 @@
* limitations under the License.
*
*/
-package org.apache.dubbo.samples.microservices.sc.rest;
+package org.apache.dubbo.demo.provider.rest;
-import org.codehaus.jackson.annotate.JsonProperty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
@@ -37,8 +35,6 @@ public class User implements Serializable {
@Min(1L)
private Long id;
- @JsonProperty("username")
- @XmlElement(name = "username")
@NotNull
@Size(min = 6, max = 50)
private String name;
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/UserService.java
similarity index 96%
rename from dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/UserService.java
index 06dcb2c..14b2f38 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserService.java
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/UserService.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package org.apache.dubbo.samples.microservices.sc.rest;
+package org.apache.dubbo.demo.provider.rest;
import org.apache.dubbo.rpc.protocol.rest.support.ContentType;
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/UserServiceImpl.java
similarity index 95%
rename from dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/UserServiceImpl.java
index fcf8875..397f437 100644
--- a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/java/org/apache/dubbo/samples/microservices/sc/rest/UserServiceImpl.java
+++ b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/java/org/apache/dubbo/demo/provider/rest/UserServiceImpl.java
@@ -16,7 +16,7 @@
* limitations under the License.
*
*/
-package org.apache.dubbo.samples.microservices.sc.rest;
+package org.apache.dubbo.demo.provider.rest;
import java.util.concurrent.atomic.AtomicLong;
diff --git a/dubbo-demo/dubbo-call-sc/consumer/src/main/resources/log4j.properties b/dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/resources/log4j.properties
similarity index 100%
rename from dubbo-demo/dubbo-call-sc/consumer/src/main/resources/log4j.properties
rename to dubbo-demo/sc-call-dubbo/sc-dubbo-provider/src/main/resources/log4j.properties
diff --git a/dubbo-demo/sc-call-dubbo/provider/pom.xml b/dubbo-demo/servicediscovery-transfer/pom.xml
similarity index 54%
rename from dubbo-demo/sc-call-dubbo/provider/pom.xml
rename to dubbo-demo/servicediscovery-transfer/pom.xml
index 9f98d0e..146e5e2 100644
--- a/dubbo-demo/sc-call-dubbo/provider/pom.xml
+++ b/dubbo-demo/servicediscovery-transfer/pom.xml
@@ -22,12 +22,41 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-call-sc</artifactId>
+ <artifactId>dubbo-demo</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
+ <packaging>pom</packaging>
- <artifactId>provider</artifactId>
+ <artifactId>servicediscovery-transfer</artifactId>
+
+ <properties>
+ <skip_maven_deploy>true</skip_maven_deploy>
+ <spring-boot-maven-plugin.version>2.1.4.RELEASE</spring-boot-maven-plugin.version>
+ </properties>
+
+ <modules>
+ <module>servicediscovery-transfer-provider</module>
+ <module>servicediscovery-transfer-consumer-old</module>
+ <module>servicediscovery-transfer-consumer</module>
+ </modules>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring-boot-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/pom.xml
similarity index 98%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
copy to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/pom.xml
index dcf6e28..c1ad6c7 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/pom.xml
@@ -23,7 +23,7 @@
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>servicediscovery-consumer</artifactId>
+ <artifactId>servicediscovery-transfer-consumer-old</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>The demo consumer module of dubbo project</description>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/java/org/apache/dubbo/demo/consumer/Application.java
similarity index 86%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
copy to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/java/org/apache/dubbo/demo/consumer/Application.java
index f448a18..2ecc664 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/java/org/apache/dubbo/demo/consumer/Application.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.demo.consumer;
import org.apache.dubbo.demo.DemoService;
+import org.apache.dubbo.demo.GreetingService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -27,5 +28,7 @@ public class Application {
DemoService demoService = context.getBean("demoService", DemoService.class);
String hello = demoService.sayHello("world");
System.out.println("result: " + hello);
+ GreetingService greetingService = context.getBean("greetingService", GreetingService.class);
+ System.out.print("greetings: " + greetingService.hello());
}
}
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/resources/dubbo.properties
similarity index 100%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties
copy to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/resources/dubbo.properties
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/resources/log4j.properties
similarity index 100%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties
copy to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/resources/log4j.properties
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/resources/spring/dubbo-consumer.xml
similarity index 85%
copy from dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
copy to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/resources/spring/dubbo-consumer.xml
index d3081f6..d2a9d7d 100644
--- a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer-old/src/main/resources/spring/dubbo-consumer.xml
@@ -21,10 +21,11 @@
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 name="servicediscovery-transfer-consumer-old"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+ <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
<dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
+ <dubbo:reference id="greetingService" check="false" interface="org.apache.dubbo.demo.GreetingService"/>
</beans>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/pom.xml
similarity index 98%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
copy to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/pom.xml
index dcf6e28..54b4509 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/pom.xml
@@ -23,7 +23,7 @@
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>servicediscovery-consumer</artifactId>
+ <artifactId>servicediscovery-transfer-consumer</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>The demo consumer module of dubbo project</description>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
similarity index 85%
copy from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
copy to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
index f448a18..14e2793 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
@@ -16,7 +16,7 @@
*/
package org.apache.dubbo.demo.consumer;
-import org.apache.dubbo.demo.DemoService;
+import org.apache.dubbo.demo.GreetingService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -24,8 +24,8 @@ public class Application {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
context.start();
- DemoService demoService = context.getBean("demoService", DemoService.class);
- String hello = demoService.sayHello("world");
+ GreetingService greetingService = context.getBean("greetingService", GreetingService.class);
+ String hello = greetingService.hello();
System.out.println("result: " + hello);
}
}
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/resources/dubbo.properties
similarity index 100%
rename from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/dubbo.properties
rename to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/resources/dubbo.properties
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/resources/log4j.properties
similarity index 100%
rename from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/log4j.properties
rename to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/resources/log4j.properties
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/resources/spring/dubbo-consumer.xml
similarity index 87%
rename from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
rename to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/resources/spring/dubbo-consumer.xml
index d3081f6..508e65e 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/resources/spring/dubbo-consumer.xml
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-consumer/src/main/resources/spring/dubbo-consumer.xml
@@ -21,10 +21,10 @@
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 name="servicediscovery-transfer-consumer"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+ <dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service"/>
- <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService"/>
+ <dubbo:reference id="greetingService" check="false" interface="org.apache.dubbo.demo.GreetingService"/>
</beans>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/pom.xml
similarity index 84%
rename from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
rename to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/pom.xml
index dcf6e28..6bd8975 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/pom.xml
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/pom.xml
@@ -23,13 +23,15 @@
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
- <artifactId>servicediscovery-consumer</artifactId>
+ <artifactId>servicediscovery-transfer-provider</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
- <description>The demo consumer module of dubbo project</description>
+ <description>The demo provider module of dubbo project</description>
<properties>
<skip_maven_deploy>true</skip_maven_deploy>
+ <slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
</properties>
+
<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
@@ -66,11 +68,11 @@
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-config-spring</artifactId>
+ <artifactId>dubbo-rpc-dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-rpc-dubbo</artifactId>
+ <artifactId>dubbo-config-spring</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
@@ -80,5 +82,18 @@
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-serialization-hessian2</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-log4j12.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
similarity index 73%
rename from dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
rename to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
index f448a18..d1ab5be 100644
--- a/dubbo-demo/servicediscovery-transfer/servicediscovery-consumer/src/main/java/org/apache/dubbo/demo/consumer/Application.java
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/java/org/apache/dubbo/demo/provider/Application.java
@@ -14,18 +14,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.demo.consumer;
-
-import org.apache.dubbo.demo.DemoService;
+package org.apache.dubbo.demo.provider;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Application {
- public static void main(String[] args) {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
+ public static void main(String[] args) throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-provider.xml");
context.start();
- DemoService demoService = context.getBean("demoService", DemoService.class);
- String hello = demoService.sayHello("world");
- System.out.println("result: " + hello);
+ System.in.read();
}
}
diff --git a/dubbo-demo/sc-call-dubbo/provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
similarity index 100%
rename from dubbo-demo/sc-call-dubbo/provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
rename to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/java/org/apache/dubbo/demo/provider/DemoServiceImpl.java
diff --git a/dubbo-demo/servicediscovery-transfer/provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java
similarity index 100%
rename from dubbo-demo/servicediscovery-transfer/provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java
rename to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/java/org/apache/dubbo/demo/provider/GreetingServiceImpl.java
diff --git a/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/resources/dubbo.properties b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/resources/dubbo.properties
new file mode 100644
index 0000000..ad602ba
--- /dev/null
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/resources/dubbo.properties
@@ -0,0 +1 @@
+dubbo.application.qos.port=22222
diff --git a/dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/resources/log4j.properties b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/resources/log4j.properties
similarity index 100%
rename from dubbo-demo/dubbo-call-sc&dubbo/consumer/src/main/resources/log4j.properties
rename to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/resources/log4j.properties
diff --git a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/resources/spring/dubbo-provider.xml
similarity index 69%
copy from dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
copy to dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/resources/spring/dubbo-provider.xml
index 1eaf379..8fd1dc5 100644
--- a/dubbo-demo/dubbo-demo-servicediscovery-xml/servicediscovery-provider/src/main/resources/spring/dubbo-provider.xml
+++ b/dubbo-demo/servicediscovery-transfer/servicediscovery-transfer-provider/src/main/resources/spring/dubbo-provider.xml
@@ -21,14 +21,19 @@
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-provider"/>
+ <dubbo:application name="servicediscovery-transfer-provider"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry.type=service"/>
+ <dubbo:registry id="service-discovery" address="zookeeper://127.0.0.1:2181?registry-type=service"/>
+ <dubbo:registry id="normal" address="zookeeper://127.0.0.1:2181"/>
<dubbo:protocol name="dubbo"/>
<bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
+ <bean id="greetingService" class="org.apache.dubbo.demo.provider.GreetingServiceImpl"/>
- <dubbo:service interface="org.apache.dubbo.demo.DemoService" ref="demoService"/>
+ <!-- only to normal registry -->
+ <dubbo:service registry="normal" interface="org.apache.dubbo.demo.DemoService" ref="demoService"/>
+ <!-- to both sides -->
+ <dubbo:service interface="org.apache.dubbo.demo.GreetingService" ref="greetingService"/>
</beans>