Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dubbo-springboot-example</artifactId>
<groupId>com.tencent.polaris</groupId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-springboot-consumer</artifactId>
<name>dubbo-springboot-consumer</name>
<description>dubbo-springboot-consumer</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-api-example</artifactId>
<version>${revision}</version>
</dependency>

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

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

<!-- 引入 polaris 注册能力 -->
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-registry-polaris</artifactId>
<version>${revision}</version>
</dependency>

<!-- 引入 polaris 元数据中心能力 -->
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-metadatareport-polaris</artifactId>
<version>${revision}</version>
</dependency>

<!-- 引入 polaris 配置中心能力 -->
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-configcenter-polaris</artifactId>
<version>${revision}</version>
</dependency>
<!-- 引入 polaris 限流能力 -->
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-ratelimit-polaris</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Tencent is pleased to support the open source community by making dubbo-polaris-java available.
*
* Copyright (C) 2021 Tencent. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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 com.tencent.polaris.dubbo.example.springboot.consumer;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableDubbo
public class DubboSpringBootConsumerApplication {

public static void main(String[] args) {
SpringApplication.run(DubboSpringBootConsumerApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Tencent is pleased to support the open source community by making dubbo-polaris-java available.
*
* Copyright (C) 2021 Tencent. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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 com.tencent.polaris.dubbo.example.springboot.consumer;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/echo")
public class EchoController {

@Autowired
private GreetingServiceConsumer greetingServiceConsumer;

@GetMapping("/echo")
public String echo(@RequestParam String value, @RequestParam String method) {
return greetingServiceConsumer.doEcho(value);
}
@GetMapping("/sayHi")
public String sayHi(@RequestParam String value, @RequestParam String method) {
return greetingServiceConsumer.doSayHi(value);
}
@GetMapping("/sayHello")
public String sayHello(@RequestParam String value, @RequestParam String method) {
return greetingServiceConsumer.doSayHello(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Tencent is pleased to support the open source community by making dubbo-polaris-java available.
*
* Copyright (C) 2021 Tencent. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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 com.tencent.polaris.dubbo.example.springboot.consumer;

import com.tencent.polaris.dubbo.example.api.EchoService;
import com.tencent.polaris.dubbo.example.api.GreetingService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;

@Component
public class GreetingServiceConsumer {

@DubboReference(version = "1.0.0")
// @DubboReference
private GreetingService greetingService;

@DubboReference(version = "1.0.0")
// @DubboReference
private EchoService echoService;

public String doSayHello(String name) {
return greetingService.sayHello(name);
}

public String doSayHi(String name) {
return greetingService.sayHi(name);
}

public String doEcho(String value) {
return echoService.echo(value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Spring Boot application
spring.application.name=dubbo-springboot-consumer

# Dubbo application
dubbo.application.name=dubbo-springboot-consumer
dubbo.application.register-mode=instance
dubbo.application.qosEnable=false
dubbo.application.service-discovery.migration=FORCE_APPLICATION
dubbo.application.metadata-type=remote

# Dubbo registry
dubbo.registry.address=polaris://119.91.66.223:8091
dubbo.registry.parameters.detect_when=after_call

# Dubbo config center
dubbo.config-center.address=polaris://119.91.66.223:8093

# Dubbo metadata report
dubbo.metadata-report.address=polaris://119.91.66.223:8091

# Dubbo consumer
dubbo.consumer.timeout=3000
dubbo.consumer.filter=polaris_report

# Dubbo protocol
dubbo.protocol.name=dubbo
dubbo.protocol.port=30881

# Dubbo provider
dubbo.provider.token=true

# Server port
server.port=15900
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>dubbo-springboot-example</artifactId>
<groupId>com.tencent.polaris</groupId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-springboot-provider</artifactId>
<name>dubbo-springboot-provider</name>
<description>dubbo-springboot-provider</description>

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

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-api-example</artifactId>
<version>${revision}</version>
</dependency>

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

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

<!-- 引入 polaris 注册能力 -->
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-registry-polaris</artifactId>
<version>${revision}</version>
</dependency>

<!-- 引入 polaris 元数据中心能力 -->
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-metadatareport-polaris</artifactId>
<version>${revision}</version>
</dependency>

<!-- 引入 polaris 配置中心能力 -->
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-configcenter-polaris</artifactId>
<version>${revision}</version>
</dependency>
<!-- 引入 polaris 限流能力 -->
<dependency>
<groupId>com.tencent.polaris</groupId>
<artifactId>dubbo-ratelimit-polaris</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Tencent is pleased to support the open source community by making dubbo-polaris-java available.
*
* Copyright (C) 2021 Tencent. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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 com.tencent.polaris.dubbo.example.springboot.provider;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableDubbo
public class DubboSpringBootProviderApplication {

public static void main(String[] args) {
SpringApplication.run(DubboSpringBootProviderApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Tencent is pleased to support the open source community by making dubbo-polaris-java available.
*
* Copyright (C) 2021 Tencent. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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 com.tencent.polaris.dubbo.example.springboot.provider;

import com.tencent.polaris.dubbo.example.api.EchoService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

//@DubboService(version = "1.0.0")
@Service
@DubboService
public class EchoServiceImpl implements EchoService {

@Override
public String echo(String value) {
String echo = "echo: " + value;
System.out.println(echo);
return echo;
}
}
Loading