Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 28 additions & 19 deletions 2-advanced/dubbo-samples-merge/case-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,58 @@ props:
ipv6Cidr: 2001:1:1::/64

services:
zookeeper:
image: zookeeper:latest

dubbo-samples-merge-provider1:
type: app
basedir: dubbo-samples-merge-provider1
mainClass: org.apache.dubbo.samples.merge.MergeProvider
systemProps:
- zookeeper.address=zookeeper
waitPortsBeforeRun:
- zookeeper:2181
mainClass: org.apache.dubbo.samples.merge.MergeProvider1
checkPorts:
- 20880
checkLog: "dubbo service started"
depends_on:
- zookeeper

dubbo-samples-merge-provider2:
type: app
basedir: dubbo-samples-merge-provider2
mainClass: org.apache.dubbo.samples.merge.MergeProvider2
systemProps:
- zookeeper.address=zookeeper
waitPortsBeforeRun:
- zookeeper:2181
- zookeeper.address=dubbo-samples-merge-provider1
- zookeeper.port=2181
- dubbo.address=dubbo-samples-merge-provider1
- dubbo.port=20880
checkPorts:
- 20881
depends_on:
- dubbo-samples-merge-provider1
waitPortsBeforeRun:
- dubbo-samples-merge-provider1:2181
- dubbo-samples-merge-provider1:20880
checkLog: "dubbo service started"

dubbo-samples-merge-consumer1:
type: test
basedir: dubbo-samples-merge-consumer1
tests:
- "**/*IT.class"
systemProps:
- zookeeper.address=dubbo-samples-merge-provider1
- zookeeper.port=2181
waitPortsBeforeRun:
- dubbo-samples-merge-provider1:20880
- dubbo-samples-merge-provider2:20881
depends_on:
- zookeeper
- dubbo-samples-merge-provider1
- dubbo-samples-merge-provider2

dubbo-samples-merge-consumer:
dubbo-samples-merge-consumer2:
type: test
basedir: dubbo-samples-merge-consumer
basedir: dubbo-samples-merge-consumer2
tests:
- "**/*IT.class"
systemProps:
- zookeeper.address=zookeeper
- zookeeper.address=dubbo-samples-merge-provider1
- zookeeper.port=2181
waitPortsBeforeRun:
- zookeeper:2181
- dubbo-samples-merge-provider1:20880
- dubbo-samples-merge-provider2:20881
depends_on:
- zookeeper
- dubbo-samples-merge-provider1
- dubbo-samples-merge-provider2

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,52 @@
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dubbo-samples-merge-consumer</artifactId>
<artifactId>dubbo-samples-merge-consumer1</artifactId>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-samples-merge-api</artifactId>
</dependency>

<!-- dubbo -->
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<artifactId>dubbo-spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-dependencies-zookeeper</artifactId>
<type>pom</type>
<exclusions>
<exclusion>
<artifactId>slf4j-reload4j</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>

<!-- spring starter -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<scope>test</scope>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
*
* 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.merge;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@EnableDubbo
@SpringBootApplication
public class MergeConsumer1 {
public static void main(String[] args) {
SpringApplication.run(MergeConsumer1.class, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@

package org.apache.dubbo.samples.merge;

import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.samples.merge.api.MergeService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import org.springframework.context.support.ClassPathXmlApplicationContext;
@Component
public class Task implements CommandLineRunner {
@DubboReference(group = "*",merger = "true")
MergeService mergeService;

public class MergeConsumer {

public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/merge-consumer.xml");
context.start();

MergeService mergeService = (MergeService) context.getBean("mergeService");
@Override
public void run(String... args) {
System.out.println(mergeService.mergeResult());
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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.

dubbo:
application:
name: merge-consumer-1
qos-enable: false
registry:
address: zookeeper://${zookeeper.address:127.0.0.1}:2181
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
package org.apache.dubbo.samples.merge;

import org.apache.dubbo.common.Version;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.registry.AddressListener;
import org.apache.dubbo.samples.merge.api.MergeService;

import org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/spring/merge-consumer.xml"})
@SpringBootTest
@RunWith(SpringRunner.class)
public class Consumer1IT {
@Autowired
@DubboReference(group = "*", merger = "true")
private MergeService mergeService;

@Test
Expand All @@ -43,7 +45,7 @@ public void test() throws Exception {
if (3 == MyAddressListener.getAddressSize()) {
break;
}
Thread.sleep(200);
Thread.sleep(300);
}
Assert.assertEquals(3, MyAddressListener.getAddressSize());
Thread.sleep(100);
Expand Down
Loading