-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
614 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 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. | ||
|
||
services: | ||
zookeeper: | ||
image: zookeeper:latest | ||
|
||
dubbo-samples-broadcast-provider1: | ||
type: app | ||
basedir: . | ||
mainClass: org.apache.dubbo.samples.broadcast.BroadcastProvider | ||
systemProps: | ||
- zookeeper.address=zookeeper | ||
- zookeeper.port=2181 | ||
- dubbo.port=20880 | ||
waitPortsBeforeRun: | ||
- zookeeper:2181 | ||
checkPorts: | ||
- 20880 | ||
checkLog: "dubbo service started" | ||
depends_on: | ||
- zookeeper | ||
|
||
dubbo-samples-broadcast-provider2: | ||
type: app | ||
basedir: . | ||
mainClass: org.apache.dubbo.samples.broadcast.BroadcastProvider2 | ||
systemProps: | ||
- zookeeper.address=zookeeper | ||
- zookeeper.port=2181 | ||
- dubbo.port=20881 | ||
waitPortsBeforeRun: | ||
- zookeeper:2181 | ||
checkPorts: | ||
- 20881 | ||
checkLog: "dubbo service started" | ||
depends_on: | ||
- zookeeper | ||
|
||
dubbo-samples-broadcast-test: | ||
type: test | ||
basedir: . | ||
tests: | ||
- "**/*IT.class" | ||
systemProps: | ||
- zookeeper.address=zookeeper | ||
- zookeeper.port=2181 | ||
waitPortsBeforeRun: | ||
- zookeeper:2181 | ||
- dubbo-samples-broadcast-provider1:20880 | ||
- dubbo-samples-broadcast-provider2:20881 | ||
depends_on: | ||
- zookeeper | ||
- dubbo-samples-broadcast-provider1 | ||
- dubbo-samples-broadcast-provider2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# | ||
# 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. | ||
# | ||
|
||
|
||
# Supported component versions of the test case | ||
|
||
# Spring app | ||
dubbo.version=2.7*, 3.* | ||
spring.version=4.*, 5.* | ||
java.version= [>= 8] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.apache.dubbo</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<artifactId>dubbo-samples-broadcast</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
|
||
<dubbo.version>3.2.6</dubbo.version> | ||
<spring.version>4.3.30.RELEASE</spring.version> | ||
<log4j2.version>2.20.0</log4j2.version> | ||
<junit.version>4.13.1</junit.version> | ||
|
||
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-framework-bom</artifactId> | ||
<version>${spring.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-bom</artifactId> | ||
<version>${dubbo.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-dependencies-zookeeper-curator5</artifactId> | ||
<version>${dubbo.version}</version> | ||
<type>pom</type> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context-support</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.dubbo</groupId> | ||
<artifactId>dubbo-dependencies-zookeeper-curator5</artifactId> | ||
<type>pom</type> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-slf4j-impl</artifactId> | ||
<version>${log4j2.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>${junit.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<profiles> | ||
<!-- For jdk 11 above JavaEE annotation --> | ||
<profile> | ||
<id>javax.annotation</id> | ||
<activation> | ||
<jdk>[1.11,)</jdk> | ||
</activation> | ||
<dependencies> | ||
<dependency> | ||
<groupId>javax.annotation</groupId> | ||
<artifactId>javax.annotation-api</artifactId> | ||
<version>1.3.2</version> | ||
</dependency> | ||
</dependencies> | ||
</profile> | ||
</profiles> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven-compiler-plugin.version}</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
39 changes: 39 additions & 0 deletions
39
...samples-broadcast/src/main/java/org/apache/dubbo/samples/broadcast/BroadcastConsumer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* | ||
* 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.broadcast; | ||
|
||
import org.apache.dubbo.samples.broadcast.api.DemoService; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
public class BroadcastConsumer { | ||
|
||
public static void main(String[] args) throws Exception { | ||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/broadcast-consumer.xml"); | ||
context.start(); | ||
|
||
DemoService demoService = (DemoService) context.getBean("demoService"); | ||
for (int i = 0; i < 10000; i++) { | ||
String hello = demoService.sayHello("world"); | ||
System.out.println(hello); | ||
Thread.sleep(2000); | ||
} | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...samples-broadcast/src/main/java/org/apache/dubbo/samples/broadcast/BroadcastProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* | ||
* 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.broadcast; | ||
|
||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
|
||
public class BroadcastProvider { | ||
|
||
public static void main(String[] args) throws Exception { | ||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/broadcast-provider.xml"); | ||
context.start(); | ||
|
||
System.out.println("dubbo service started"); | ||
new CountDownLatch(1).await(); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
...amples-broadcast/src/main/java/org/apache/dubbo/samples/broadcast/BroadcastProvider2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* | ||
* 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.broadcast; | ||
|
||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
|
||
public class BroadcastProvider2 { | ||
|
||
public static void main(String[] args) throws Exception { | ||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/broadcast-provider2.xml"); | ||
context.start(); | ||
|
||
System.out.println("dubbo service started"); | ||
new CountDownLatch(1).await(); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
...o-samples-broadcast/src/main/java/org/apache/dubbo/samples/broadcast/api/DemoService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* | ||
* 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.broadcast.api; | ||
|
||
public interface DemoService { | ||
|
||
String sayHello(String name); | ||
|
||
boolean isInvoke(); | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...ples-broadcast/src/main/java/org/apache/dubbo/samples/broadcast/impl/DemoServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* | ||
* 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.broadcast.impl; | ||
|
||
import org.apache.dubbo.rpc.RpcContext; | ||
import org.apache.dubbo.samples.broadcast.api.DemoService; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
public class DemoServiceImpl implements DemoService { | ||
|
||
boolean isInvoke; | ||
@Override | ||
public String sayHello(String name) { | ||
isInvoke = true; | ||
System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] Hello " + | ||
name + ", request from consumer: " + RpcContext.getContext().getRemoteAddress()); | ||
return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress(); | ||
} | ||
|
||
@Override | ||
public boolean isInvoke() { | ||
System.out.println("The value of isInvoke:" + isInvoke); | ||
return isInvoke; | ||
} | ||
|
||
} |
Oops, something went wrong.