You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ba...@apache.org on 2021/04/22 10:06:40 UTC
[dubbo-go-samples] branch service-discovery-sample created (now
846e23e)
This is an automated email from the ASF dual-hosted git repository.
baze pushed a change to branch service-discovery-sample
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git.
at 846e23e java service discovery sample
This branch includes the following new commits:
new 846e23e java service discovery sample
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[dubbo-go-samples] 01/01: java service discovery sample
Posted by ba...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
baze pushed a commit to branch service-discovery-sample
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
commit 846e23e2043ec372ef04e7eb43bbbf539fc3dab6
Author: Patrick <dr...@foxmail.com>
AuthorDate: Thu Apr 22 18:06:20 2021 +0800
java service discovery sample
---
.../zookeeper/go-client/conf/client.yml | 1 +
.../zookeeper/go-server/conf/server.yml | 1 +
.../servicediscovery/zookeeper/java-client/pom.xml | 115 +++++++++++++++++++
.../main/java/org/apache/dubbo/Application.java | 37 +++++++
.../src/main/java/org/apache/dubbo/User.java | 68 ++++++++++++
.../main/java/org/apache/dubbo/UserProvider.java | 13 +++
.../src/main/resources/dubbo.properties | 1 +
.../src/main/resources/log4j.properties | 7 ++
.../src/main/resources/spring/dubbo-consumer.xml | 33 ++++++
.../servicediscovery/zookeeper/java-server/pom.xml | 122 +++++++++++++++++++++
.../main/java/org/apache/dubbo/Application.java | 31 ++++++
.../src/main/java/org/apache/dubbo/User.java | 68 ++++++++++++
.../main/java/org/apache/dubbo/UserProvider.java | 13 +++
.../java/org/apache/dubbo/UserProviderImpl.java | 21 ++++
.../src/main/resources/dubbo.properties | 1 +
.../src/main/resources/log4j.properties | 7 ++
.../src/main/resources/spring/dubbo-provider.xml | 38 +++++++
17 files changed, 577 insertions(+)
diff --git a/registry/servicediscovery/zookeeper/go-client/conf/client.yml b/registry/servicediscovery/zookeeper/go-client/conf/client.yml
index 7cd78f1..50241af 100644
--- a/registry/servicediscovery/zookeeper/go-client/conf/client.yml
+++ b/registry/servicediscovery/zookeeper/go-client/conf/client.yml
@@ -41,6 +41,7 @@ service_discovery:
references:
"UserProvider":
registry: "demoServiceDiscovery"
+ provided-by: "UserInfoServer"
protocol: "dubbo"
interface: "org.apache.dubbo.UserProvider"
cluster: "failover"
diff --git a/registry/servicediscovery/zookeeper/go-server/conf/server.yml b/registry/servicediscovery/zookeeper/go-server/conf/server.yml
index 3fddf62..f67a386 100644
--- a/registry/servicediscovery/zookeeper/go-server/conf/server.yml
+++ b/registry/servicediscovery/zookeeper/go-server/conf/server.yml
@@ -7,6 +7,7 @@ application:
module: "dubbo-go user-info server"
version: "0.0.1"
environment: "dev"
+ metadataType: "remote"
# registry config
registries:
diff --git a/registry/servicediscovery/zookeeper/java-client/pom.xml b/registry/servicediscovery/zookeeper/java-client/pom.xml
new file mode 100644
index 0000000..a68afcf
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-client/pom.xml
@@ -0,0 +1,115 @@
+<!--
+ 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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>servicediscovery-consumer</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>0.0.1</version>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
+ <description>The demo consumer module of dubbo project</description>
+ <properties>
+ <skip_maven_deploy>true</skip_maven_deploy>
+ <skip_maven_deploy>true</skip_maven_deploy>
+ <spring-boot-maven-plugin.version>2.1.4.RELEASE</spring-boot-maven-plugin.version>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <skip_maven_deploy>true</skip_maven_deploy>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ <spring.version>4.3.16.RELEASE</spring.version>
+ <dubbo.version>3.0.0.preview</dubbo.version>
+ <junit.version>4.12</junit.version>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-registry-multicast</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-registry-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-configcenter-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-configcenter-nacos</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-metadata-report-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-rpc-dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-config-spring</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-netty4</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-serialization-hessian2</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-framework-bom</artifactId>
+ <version>${spring.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+
+ <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/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/Application.java b/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/Application.java
new file mode 100644
index 0000000..feb1754
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/Application.java
@@ -0,0 +1,37 @@
+/*
+ * 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;
+
+import org.apache.dubbo.UserProvider;
+import org.apache.dubbo.User;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class Application {
+ public static void main(String[] args) {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-consumer.xml");
+ context.start();
+ UserProvider demoService = context.getBean("userProvider", UserProvider.class);
+// try {
+// Thread.sleep(100000);
+// } catch (Exception e) {
+// }
+ User user = demoService.GetUser("A001");
+
+ System.out.println("result: " + user);
+ }
+}
diff --git a/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/User.java b/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/User.java
new file mode 100644
index 0000000..6cdc73b
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/User.java
@@ -0,0 +1,68 @@
+package org.apache.dubbo;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *@author Patrick Jiang
+ *@Description
+ *@date 2021/4/19 5:04 下午
+ */
+public class User implements Serializable {
+
+ public User(String id, String name, int age) {
+ this.id = id;
+ this.name = name;
+ this.age = age;
+ }
+
+ private String id;
+
+ private String name;
+
+ private int age;
+
+ private Date time = new Date();
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ @Override
+ public String toString() {
+ return "User{" +
+ "id='" + id + '\'' +
+ ", name='" + name + '\'' +
+ ", age=" + age +
+ ", time=" + time +
+ '}';
+ }
+}
diff --git a/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/UserProvider.java b/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/UserProvider.java
new file mode 100644
index 0000000..7214ad5
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-client/src/main/java/org/apache/dubbo/UserProvider.java
@@ -0,0 +1,13 @@
+package org.apache.dubbo;
+
+import org.apache.dubbo.User;
+
+/**
+ *@author Patrick Jiang
+ *@Description
+ *@date 2021/4/19 4:57 下午
+ */
+public interface UserProvider {
+ User GetUser(String userId);
+}
+
diff --git a/registry/servicediscovery/zookeeper/java-client/src/main/resources/dubbo.properties b/registry/servicediscovery/zookeeper/java-client/src/main/resources/dubbo.properties
new file mode 100644
index 0000000..8c3cb25
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-client/src/main/resources/dubbo.properties
@@ -0,0 +1 @@
+dubbo.application.qos.port=33333
diff --git a/registry/servicediscovery/zookeeper/java-client/src/main/resources/log4j.properties b/registry/servicediscovery/zookeeper/java-client/src/main/resources/log4j.properties
new file mode 100644
index 0000000..2424381
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-client/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/registry/servicediscovery/zookeeper/java-client/src/main/resources/spring/dubbo-consumer.xml b/registry/servicediscovery/zookeeper/java-client/src/main/resources/spring/dubbo-consumer.xml
new file mode 100644
index 0000000..6debd89
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-client/src/main/resources/spring/dubbo-consumer.xml
@@ -0,0 +1,33 @@
+<?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.
+ -->
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
+ 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:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181?registry-type=service"/>
+<!-- <dubbo:registry address="nacos://${nacos.address:127.0.0.1}:8848?registry-type=service"/>-->
+
+ <dubbo:metadata-report address="zookeeper://${zookeeper.address:127.0.0.1}:2181" />
+
+ <dubbo:reference id="userProvider" check="true" interface="org.apache.dubbo.UserProvider" provided-by="UserInfoServer"/>
+
+</beans>
diff --git a/registry/servicediscovery/zookeeper/java-server/pom.xml b/registry/servicediscovery/zookeeper/java-server/pom.xml
new file mode 100644
index 0000000..ba32f12
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-server/pom.xml
@@ -0,0 +1,122 @@
+<!--
+ 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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>servicediscovery-provider</artifactId>
+ <groupId>org.apache.dubbo</groupId>
+ <version>0.0.1</version>
+ <packaging>jar</packaging>
+ <name>${project.artifactId}</name>
+ <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>
+ <skip_maven_deploy>true</skip_maven_deploy>
+ <spring-boot-maven-plugin.version>2.1.4.RELEASE</spring-boot-maven-plugin.version>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <skip_maven_deploy>true</skip_maven_deploy>
+ <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+ <spring.version>4.3.16.RELEASE</spring.version>
+ <dubbo.version>3.0.0.preview</dubbo.version>
+ <junit.version>4.12</junit.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-registry-multicast</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-registry-nacos</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-registry-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-configcenter-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-configcenter-nacos</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-metadata-report-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-rpc-dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-config-spring</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-remoting-netty4</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-serialization-hessian2</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-log4j12.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-framework-bom</artifactId>
+ <version>${spring.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+
+ <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/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/Application.java b/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/Application.java
new file mode 100644
index 0000000..e4e1d3d
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/Application.java
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.util.concurrent.CountDownLatch;
+
+public class Application {
+ public static void main(String[] args) throws Exception {
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/dubbo-provider.xml");
+ context.start();
+
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
+ }
+}
diff --git a/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/User.java b/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/User.java
new file mode 100644
index 0000000..6cdc73b
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/User.java
@@ -0,0 +1,68 @@
+package org.apache.dubbo;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ *@author Patrick Jiang
+ *@Description
+ *@date 2021/4/19 5:04 下午
+ */
+public class User implements Serializable {
+
+ public User(String id, String name, int age) {
+ this.id = id;
+ this.name = name;
+ this.age = age;
+ }
+
+ private String id;
+
+ private String name;
+
+ private int age;
+
+ private Date time = new Date();
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public Date getTime() {
+ return time;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+ @Override
+ public String toString() {
+ return "User{" +
+ "id='" + id + '\'' +
+ ", name='" + name + '\'' +
+ ", age=" + age +
+ ", time=" + time +
+ '}';
+ }
+}
diff --git a/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/UserProvider.java b/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/UserProvider.java
new file mode 100644
index 0000000..7214ad5
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/UserProvider.java
@@ -0,0 +1,13 @@
+package org.apache.dubbo;
+
+import org.apache.dubbo.User;
+
+/**
+ *@author Patrick Jiang
+ *@Description
+ *@date 2021/4/19 4:57 下午
+ */
+public interface UserProvider {
+ User GetUser(String userId);
+}
+
diff --git a/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/UserProviderImpl.java b/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/UserProviderImpl.java
new file mode 100644
index 0000000..1378b00
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-server/src/main/java/org/apache/dubbo/UserProviderImpl.java
@@ -0,0 +1,21 @@
+package org.apache.dubbo;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.rpc.RpcContext;
+
+/**
+ *@author Patrick Jiang
+ *@Description
+ *@date 2021/4/19 5:06 下午
+ */
+public class UserProviderImpl implements UserProvider {
+ private static final Logger logger = LoggerFactory.getLogger(UserProviderImpl.class);
+
+ @Override
+ public User GetUser(String userId) {
+ logger.info("Hello " + userId + ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
+ return new User(userId, "Alex Stocks", 18);
+ }
+}
+
diff --git a/registry/servicediscovery/zookeeper/java-server/src/main/resources/dubbo.properties b/registry/servicediscovery/zookeeper/java-server/src/main/resources/dubbo.properties
new file mode 100644
index 0000000..ad602ba
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-server/src/main/resources/dubbo.properties
@@ -0,0 +1 @@
+dubbo.application.qos.port=22222
diff --git a/registry/servicediscovery/zookeeper/java-server/src/main/resources/log4j.properties b/registry/servicediscovery/zookeeper/java-server/src/main/resources/log4j.properties
new file mode 100644
index 0000000..15a0900
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-server/src/main/resources/log4j.properties
@@ -0,0 +1,7 @@
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy HH:mm:ss:SSS z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/registry/servicediscovery/zookeeper/java-server/src/main/resources/spring/dubbo-provider.xml b/registry/servicediscovery/zookeeper/java-server/src/main/resources/spring/dubbo-provider.xml
new file mode 100644
index 0000000..d50d292
--- /dev/null
+++ b/registry/servicediscovery/zookeeper/java-server/src/main/resources/spring/dubbo-provider.xml
@@ -0,0 +1,38 @@
+<?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.
+ -->
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans"
+ 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="UserInfoServer" metadata-type="local"/>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181?registry-type=service"/>
+<!-- <dubbo:registry address="nacos://${nacos.address:127.0.0.1}:8848?registry-type=service"/>-->
+
+ <dubbo:protocol name="dubbo" port="20880"/>
+
+<!-- <dubbo:metadata-report address="nacos://${nacos.address:127.0.0.1}:8848" />-->
+ <dubbo:metadata-report address="zookeeper://${zookeeper.address:127.0.0.1}:2181" />
+
+ <bean id="userProvider" class="org.apache.dubbo.UserProviderImpl"/>
+
+ <dubbo:service interface="org.apache.dubbo.UserProvider" ref="userProvider" weight="12"/>
+
+</beans>