1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

merge from 2.2.4.RELEASE

This commit is contained in:
theonefx
2021-01-18 17:30:10 +08:00
134 changed files with 1467 additions and 1214 deletions

View File

@@ -15,6 +15,7 @@
<description>Example demonstrating how to use nacos config</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -175,7 +175,7 @@ AccessKey|spring.cloud.nacos.config.access-key||
SecretKey|spring.cloud.nacos.config.secret-key||
相对路径|spring.cloud.nacos.config.context-path||服务端 API 的相对路径
接入点|spring.cloud.nacos.config.endpoint|UTF-8|地域的某个服务的入口域名,通过此域名可以动态地拿到服务端地址
是否开启监听和自动刷新|spring.cloud.nacos.config.refresh.enabled|true|
是否开启监听和自动刷新|spring.cloud.nacos.config.refresh-enabled|true|

View File

@@ -25,6 +25,7 @@ Before we start the demo, let's learn how to connect Nacos Config to a Spring Cl
spring.cloud.nacos.config.server-addr=127.0.0.1:8848
3. After completing the above two steps, the application will get the externalized configuration from Nacos Server and put it in the Spring Environment's PropertySources.We use the @Value annotation to inject the corresponding configuration into the userName and age fields of the SampleController, and add @RefreshScope to turn on dynamic refresh .
@RefreshScope
class SampleController {

View File

@@ -18,6 +18,7 @@ package com.alibaba.cloud.examples;
import java.io.IOException;
import java.io.StringReader;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
@@ -34,7 +35,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -62,8 +65,12 @@ class UserConfig {
private String name;
private String hr;
private Map<String, Object> map;
private List<User> users;
public int getAge() {
return age;
}
@@ -88,10 +95,65 @@ class UserConfig {
this.map = map;
}
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public String getHr() {
return hr;
}
public void setHr(String hr) {
this.hr = hr;
}
@Override
public String toString() {
return "UserConfig{" + "age=" + age + ", name='" + name + '\'' + ", map=" + map
+ '}';
+ ", hr='" + hr + '\'' + ", users=" + users + '}';
}
public static class User {
private String name;
private String hr;
private String avg;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getHr() {
return hr;
}
public void setHr(String hr) {
this.hr = hr;
}
public String getAvg() {
return avg;
}
public void setAvg(String avg) {
this.avg = avg;
}
@Override
public String toString() {
return "User{" + "name='" + name + '\'' + ", hr=" + hr + ", avg=" + avg + '}';
}
}
}
@@ -99,7 +161,7 @@ class UserConfig {
@Component
class SampleRunner implements ApplicationRunner {
@Value("${user.name}")
@Value("${user.name:zz}")
String userName;
@Value("${user.age:25}")
@@ -156,7 +218,10 @@ class SampleController {
@Autowired
private NacosConfigManager nacosConfigManager;
@Value("${user.name}")
@Autowired
private Environment environment;
@Value("${user.name:zz}")
String userName;
@Value("${user.age:25}")
@@ -168,6 +233,11 @@ class SampleController {
+ userConfig + "!" + nacosConfigManager.getConfigService();
}
@RequestMapping("/get/{name}")
public String getValue(@PathVariable String name) {
return String.valueOf(environment.getProperty(name));
}
@RequestMapping("/bool")
public boolean bool() {
return (Boolean) (userConfig.getMap().get("2"));

View File

@@ -5,19 +5,26 @@ spring.cloud.nacos.config.server-addr=127.0.0.1:8848
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos
#spring.cloud.nacos.config.namespace=public
spring.cloud.nacos.config.name=test-aaa
spring.cloud.nacos.config.file-extension=yaml
#spring.cloud.nacos.config.refreshable-dataids=common.properties
#spring.cloud.nacos.config.shared-data-ids=common.properties,base-common.properties
spring.cloud.nacos.config.shared-configs[0]= common333.properties
spring.cloud.nacos.config.shared-configs[1].data-id= common111.properties
spring.cloud.nacos.config.shared-configs[1].group= GROUP_APP1
spring.cloud.nacos.config.shared-configs[1].refresh= true
spring.cloud.nacos.config.shared-configs[2]= common222.properties
#spring.cloud.nacos.config.shared-configs[0]= common333.properties
#spring.cloud.nacos.config.shared-configs[1].data-id= common111.properties
#spring.cloud.nacos.config.shared-configs[1].group= GROUP_APP1
#spring.cloud.nacos.config.shared-configs[1].refresh= true
#spring.cloud.nacos.config.shared-configs[2]= common222.properties
spring.cloud.nacos.config.shared-configs[0].data-id= test2.yaml
spring.cloud.nacos.config.shared-configs[0].refresh=true
#spring.cloud.nacos.config.ext-config[0]=ext.properties
spring.cloud.nacos.config.extension-configs[0].data-id= extension1.properties
spring.cloud.nacos.config.extension-configs[0].refresh= true
spring.cloud.nacos.config.extension-configs[1]= extension2.properties
spring.cloud.nacos.config.extension-configs[2].data-id= extension3.json
spring.cloud.nacos.config.extension-configs[0].refresh=true
spring.cloud.nacos.config.extension-configs[1].data-id= test1.yml
spring.cloud.nacos.config.extension-configs[1].refresh= true

View File

@@ -15,6 +15,7 @@
<description>Example demonstrating how to use nacos discovery</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -9,11 +9,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nacos-discovery-provider-example</artifactId>
<name>Spring Cloud Starter Alibaba Nacos Discovery Provider Example</name>
<description>Example demonstrating how to use nacos discovery</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -1,6 +1,7 @@
server.port=18082
spring.application.name=service-provider
spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
#spring.cloud.nacos.discovery.instance-enabled=true
spring.cloud.nacos.username=nacos
spring.cloud.nacos.password=nacos

View File

@@ -9,11 +9,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nacos-discovery-spring-cloud-config-client-example</artifactId>
<name>Spring Cloud Starter Alibaba Nacos Discovery x Config Client Example</name>
<description>Example demonstrating how to use nacos discovery</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -9,11 +9,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nacos-discovery-spring-cloud-config-server-example</artifactId>
<name>Spring Cloud Starter Alibaba Nacos Discovery x Config Server Example</name>
<description>Example demonstrating how to use nacos discovery</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -15,6 +15,7 @@
<description>Example demonstrating how to use nacos discovery</description>
<packaging>pom</packaging>
<modules>
<module>nacos-discovery-consumer-example</module>
<module>nacos-discovery-provider-example</module>

View File

@@ -30,7 +30,7 @@
public class ProviderApplication {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
SpringApplication.run(ProviderApplication.class, args);
}
@RestController

View File

@@ -29,7 +29,7 @@ Before we start the demo, let's learn how to connect Nacos Config to a Spring Cl
public class ProviderApplication {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
SpringApplication.run(ProviderApplication.class, args);
}
@RestController
@@ -207,6 +207,7 @@ Metadata|spring.cloud.nacos.discovery.metadata||Extended data, Configure using M
log name|spring.cloud.nacos.discovery.log-name||
endpoint|spring.cloud.nacos.discovery.endpoint||The domain name of a service, through which the server address can be dynamically obtained.
Integration Ribbon|ribbon.nacos.enabled|true|
enabled|spring.cloud.nacos.discovery.enabled|true|The switch to enable or disable nacos service discovery

View File

@@ -9,11 +9,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nacos-gateway-discovery-example</artifactId>
<name>Spring Cloud Starter Alibaba Nacos Discovery x Gateway Example</name>
<description>Example demonstrating how to use gateway with nacos</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -9,11 +9,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nacos-gateway-provider-example</artifactId>
<name>Spring Cloud Starter Alibaba Nacos Discovery x Gateway - Provider Example</name>
<description>Example demonstrating how to use gateway with nacos</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -10,11 +10,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>nacos-gateway-example</artifactId>
<name>Spring Cloud Starter Alibaba Nacos Discovery x Gateway Examples</name>
<description>Example demonstrating how to use gateway with nacos</description>
<packaging>pom</packaging>
<modules>
<module>nacos-gateway-discovery-example</module>
<module>nacos-gateway-provider-example</module>

View File

@@ -10,11 +10,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rocketmq-consume-example</artifactId>
<name>Spring Cloud Starter Stream Alibaba RocketMQ Consume Example</name>
<description>Example demonstrating how to use rocketmq consume</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>

View File

@@ -10,11 +10,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>rocketmq-produce-example</artifactId>
<name>Spring Cloud Starter Stream Alibaba RocketMQ Produce Example</name>
<description>Example demonstrating how to use rocketmq produce</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.alibaba.cloud</groupId>

View File

@@ -83,7 +83,7 @@ public class RocketMQProduceApplication {
@Override
public void run(String... args) throws Exception {
if (this.bindingName.equals("output1")) {
if ("output1".equals(this.bindingName)) {
int count = 5;
for (int index = 1; index <= count; index++) {
String msgContent = "msg-" + index;
@@ -98,7 +98,7 @@ public class RocketMQProduceApplication {
}
}
}
else if (this.bindingName.equals("output3")) {
else if ("output3".equals(this.bindingName)) {
int count = 20;
for (int index = 1; index <= count; index++) {
String msgContent = "pullMsg-" + index;

View File

@@ -9,8 +9,8 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>account-service</artifactId>
<artifactId>account-service</artifactId>
<name>Spring Cloud Starter Alibaba Seata Example - Account Service</name>
<packaging>jar</packaging>

View File

@@ -1,67 +0,0 @@
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = false
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
worker-thread-prefix = "NettyServerNIOWorker"
server-executor-thread-prefix = "NettyServerBizHandler"
share-boss-worker = false
client-selector-thread-prefix = "NettyClientSelector"
client-selector-thread-size = 1
client-worker-thread-prefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
boss-thread-size = 1
#auto default pin or 8
worker-thread-size = 8
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#vgroup->rgroup
vgroup_mapping.account-service-seata-service-group = "default"
#only support single node
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
}
client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
}
report.retry.count = 5
tm.commit.retry.count = 1
tm.rollback.retry.count = 1
}
transaction {
undo.data.validation = true
undo.log.serialization = "jackson"
undo.log.save.days = 7
#schedule delete expired undo_log in milliseconds
undo.log.delete.period = 86400000
undo.log.table = "undo_log"
}
support {
## spring
spring {
# auto proxy the DataSource bean
datasource.autoproxy = false
}
}

View File

@@ -1,73 +0,0 @@
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "http://localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
etcd3 {
serverAddr = "http://localhost:2379"
}
file {
name = "file.conf"
}
}

View File

@@ -9,8 +9,8 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>business-service</artifactId>
<artifactId>business-service</artifactId>
<name>Spring Cloud Starter Alibaba Seata Example - Business Service</name>
<packaging>jar</packaging>
@@ -31,6 +31,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springframework.cloud</groupId>-->
<!-- <artifactId>spring-cloud-starter-loadbalancer</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

View File

@@ -5,6 +5,8 @@ spring.cloud.nacos.discovery.server-addr=localhost:8848
#feign.hystrix.enabled=true
#feign.sentinel.enabled=true
feign.client.config.default.connectTimeout=10000
feign.client.config.default.readTimeout=10000
logging.level.io.seata=debug

View File

@@ -1,67 +0,0 @@
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = false
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
worker-thread-prefix = "NettyServerNIOWorker"
server-executor-thread-prefix = "NettyServerBizHandler"
share-boss-worker = false
client-selector-thread-prefix = "NettyClientSelector"
client-selector-thread-size = 1
client-worker-thread-prefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
boss-thread-size = 1
#auto default pin or 8
worker-thread-size = 8
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#vgroup->rgroup
vgroup_mapping.business-service-seata-service-group = "default"
#only support single node
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
}
client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
}
report.retry.count = 5
tm.commit.retry.count = 1
tm.rollback.retry.count = 1
}
transaction {
undo.data.validation = true
undo.log.serialization = "jackson"
undo.log.save.days = 7
#schedule delete expired undo_log in milliseconds
undo.log.delete.period = 86400000
undo.log.table = "undo_log"
}
support {
## spring
spring {
# auto proxy the DataSource bean
datasource.autoproxy = false
}
}

View File

@@ -1,73 +0,0 @@
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "http://localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
etcd3 {
serverAddr = "http://localhost:2379"
}
file {
name = "file.conf"
}
}

View File

@@ -9,9 +9,9 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>order-service</artifactId>
<name>Spring Cloud Starter Alibaba Seata Example - Business Service</name>
<artifactId>order-service</artifactId>
<name>Spring Cloud Starter Alibaba Seata Example - Order Service</name>
<packaging>jar</packaging>
<dependencies>
@@ -54,4 +54,4 @@
</dependencies>
</project>
</project>

View File

@@ -25,10 +25,10 @@ import org.springframework.web.client.RestTemplate;
* @author xiaojing
*/
@SpringBootApplication
public class OderApplication {
public class OrderApplication {
public static void main(String[] args) {
SpringApplication.run(OderApplication.class, args);
SpringApplication.run(OrderApplication.class, args);
}
@Bean

View File

@@ -1,67 +0,0 @@
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = false
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
worker-thread-prefix = "NettyServerNIOWorker"
server-executor-thread-prefix = "NettyServerBizHandler"
share-boss-worker = false
client-selector-thread-prefix = "NettyClientSelector"
client-selector-thread-size = 1
client-worker-thread-prefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
boss-thread-size = 1
#auto default pin or 8
worker-thread-size = 8
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#vgroup->rgroup
vgroup_mapping.order-service-seata-service-group = "default"
#only support single node
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
}
client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
}
report.retry.count = 5
tm.commit.retry.count = 1
tm.rollback.retry.count = 1
}
transaction {
undo.data.validation = true
undo.log.serialization = "jackson"
undo.log.save.days = 7
#schedule delete expired undo_log in milliseconds
undo.log.delete.period = 86400000
undo.log.table = "undo_log"
}
support {
## spring
spring {
# auto proxy the DataSource bean
datasource.autoproxy = false
}
}

View File

@@ -1,73 +0,0 @@
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "http://localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
etcd3 {
serverAddr = "http://localhost:2379"
}
file {
name = "file.conf"
}
}

View File

@@ -9,6 +9,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>storage-service</artifactId>
<name>Spring Cloud Starter Alibaba Seata Example - Storage Service</name>
<packaging>jar</packaging>

View File

@@ -1,67 +0,0 @@
transport {
# tcp udt unix-domain-socket
type = "TCP"
#NIO NATIVE
server = "NIO"
#enable heartbeat
heartbeat = false
#thread factory for netty
thread-factory {
boss-thread-prefix = "NettyBoss"
worker-thread-prefix = "NettyServerNIOWorker"
server-executor-thread-prefix = "NettyServerBizHandler"
share-boss-worker = false
client-selector-thread-prefix = "NettyClientSelector"
client-selector-thread-size = 1
client-worker-thread-prefix = "NettyClientWorkerThread"
# netty boss thread size,will not be used for UDT
boss-thread-size = 1
#auto default pin or 8
worker-thread-size = 8
}
shutdown {
# when destroy server, wait seconds
wait = 3
}
serialization = "seata"
compressor = "none"
}
service {
#vgroup->rgroup
vgroup_mapping.storage-service-seata-service-group = "default"
#only support single node
default.grouplist = "127.0.0.1:8091"
#degrade current not support
enableDegrade = false
#disable
disable = false
#unit ms,s,m,h,d represents milliseconds, seconds, minutes, hours, days, default permanent
max.commit.retry.timeout = "-1"
max.rollback.retry.timeout = "-1"
}
client {
async.commit.buffer.limit = 10000
lock {
retry.internal = 10
retry.times = 30
}
report.retry.count = 5
tm.commit.retry.count = 1
tm.rollback.retry.count = 1
}
transaction {
undo.data.validation = true
undo.log.serialization = "jackson"
undo.log.save.days = 7
#schedule delete expired undo_log in milliseconds
undo.log.delete.period = 86400000
undo.log.table = "undo_log"
}
support {
## spring
spring {
# auto proxy the DataSource bean
datasource.autoproxy = false
}
}

View File

@@ -1,73 +0,0 @@
registry {
# file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
cluster = "default"
}
eureka {
serviceUrl = "http://localhost:8761/eureka"
application = "default"
weight = "1"
}
redis {
serverAddr = "localhost:6379"
db = "0"
}
zk {
cluster = "default"
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
consul {
cluster = "default"
serverAddr = "127.0.0.1:8500"
}
etcd3 {
cluster = "default"
serverAddr = "http://localhost:2379"
}
sofa {
serverAddr = "127.0.0.1:9603"
application = "default"
region = "DEFAULT_ZONE"
datacenter = "DefaultDataCenter"
cluster = "default"
group = "SEATA_GROUP"
addressWaitTime = "3000"
}
file {
name = "file.conf"
}
}
config {
# file、nacos 、apollo、zk、consul、etcd3
type = "file"
nacos {
serverAddr = "localhost"
namespace = ""
}
consul {
serverAddr = "127.0.0.1:8500"
}
apollo {
app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801"
}
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
}
etcd3 {
serverAddr = "http://localhost:2379"
}
file {
name = "file.conf"
}
}

View File

@@ -22,6 +22,11 @@
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-sentinel-datasource</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
@@ -35,10 +40,10 @@
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>com.alibaba.csp</groupId>-->
<!--<artifactId>sentinel-datasource-nacos</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>com.alibaba.csp</groupId>-->
<!--<artifactId>sentinel-datasource-zookeeper</artifactId>-->

View File

@@ -9,11 +9,19 @@ management.health.diskspace.enabled=false
spring.cloud.sentinel.transport.dashboard=localhost:8080
spring.cloud.sentinel.eager=true
spring.cloud.sentinel.web-context-unify=true
#spring.cloud.sentinel.block-page=/errorPage
#spring.cloud.sentinel.filter.enabled=false
#spring.cloud.sentinel.http-method-specify=false
#spring.cloud.sentinel.datasource.ds6.nacos.server-addr=127.0.0.1:8848
#spring.cloud.sentinel.datasource.ds6.nacos.username=nacos
#spring.cloud.sentinel.datasource.ds6.nacos.password=nacos
#spring.cloud.sentinel.datasource.ds6.nacos.dataId=flowrule.json
#spring.cloud.sentinel.datasource.ds6.nacos.data-type=json
#spring.cloud.sentinel.datasource.ds6.nacos.rule-type=flow
spring.cloud.sentinel.datasource.ds1.file.file=classpath: flowrule.json
spring.cloud.sentinel.datasource.ds1.file.data-type=json
spring.cloud.sentinel.datasource.ds1.file.rule-type=flow

View File

@@ -10,11 +10,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sentinel-dubbo-consumer-example</artifactId>
<name>Spring Cloud Starter Alibaba Sentinel x Dubbo - Consumer Example</name>
<description>Example demonstrating how to use sentinel with dubbo</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
@@ -30,7 +32,7 @@
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>sentinel-dubbo-api</artifactId>
<version>${revision}</version>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@@ -10,11 +10,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sentinel-dubbo-provider-example</artifactId>
<name>Spring Cloud Starter Alibaba Sentinel x Dubbo - Provider Example</name>
<description>Example demonstrating how to use sentinel with dubbo</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
@@ -30,7 +32,7 @@
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>sentinel-dubbo-api</artifactId>
<version>${revision}</version>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@@ -10,11 +10,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sentinel-feign-consumer-example</artifactId>
<name>Spring Cloud Starter Alibaba Sentinel x Feign - Consumer Example</name>
<description>Example demonstrating how to use sentinel with feign</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -20,7 +20,6 @@ import com.alibaba.cloud.examples.service.EchoService;
/**
* @author lengleng
* @date 2019-08-01
* <p>
* sentinel 降级处理
*/
@@ -35,7 +34,7 @@ public class EchoServiceFallback implements EchoService {
/**
* 调用服务提供方的输出接口.
* @param str 用户输入
* @return
* @return String
*/
@Override
public String echo(String str) {

View File

@@ -22,7 +22,6 @@ import org.springframework.stereotype.Component;
/**
* @author lengleng
* @date 2019-08-01
*/
@Component
public class EchoServiceFallbackFactory implements FallbackFactory<EchoServiceFallback> {

View File

@@ -24,7 +24,6 @@ import org.springframework.web.bind.annotation.PathVariable;
/**
* @author lengleng
* @date 2019-08-01
* <p>
* example feign client
*/

View File

@@ -22,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
/**
* @author lengleng
* @date 2019-08-01
*/
@RestController
public class EchoController {

View File

@@ -10,11 +10,13 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sentinel-webflux-example</artifactId>
<name>Spring Cloud Starter Alibaba Sentinel x WebFlux Example</name>
<description>Example demonstrating how to use sentinel with webflux</description>
<packaging>jar</packaging>
<dependencies>
<dependency>

View File

@@ -41,10 +41,10 @@ public class ZuulConfiguration {
@Override
public BlockResponse fallbackResponse(String route, Throwable cause) {
if (route.equals("my-service3")) {
if ("my-service3".equals(route)) {
return new BlockResponse(433, "Sentinel Block3", route);
}
else if (route.equals("my-service4")) {
else if ("my-service4".equals(route)) {
return new BlockResponse(444, "my-service4", route);
}
else {

View File

@@ -13,14 +13,13 @@
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-dubbo-client-sample</artifactId>
<name>Spring Cloud Dubbo Client Sample</name>
<version>${revision}</version>
<dependencies>
<!-- Sample API -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-dubbo-sample-api</artifactId>
<version>${revision}</version>
<version>${project.version}</version>
</dependency>
<!-- Spring Boot dependencies -->

View File

@@ -17,7 +17,7 @@
package com.alibaba.cloud.dubbo.bootstrap;
import com.alibaba.cloud.dubbo.service.EchoService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -27,13 +27,15 @@ import org.springframework.web.bind.annotation.RestController;
/**
* Dubbo Spring Cloud Client Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration
@RestController
public class DubboSpringCloudClientBootstrap {
@Reference
@DubboReference
private EchoService echoService;
@GetMapping("/echo")

View File

@@ -1,6 +1,9 @@
dubbo:
cloud:
subscribed-services: spring-cloud-alibaba-dubbo-server
protocols:
dubbo:
port: -1
spring:
application:

View File

@@ -23,7 +23,7 @@ import com.alibaba.cloud.dubbo.annotation.DubboTransported;
import com.alibaba.cloud.dubbo.service.RestService;
import com.alibaba.cloud.dubbo.service.User;
import com.alibaba.cloud.dubbo.service.UserService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -52,6 +52,8 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
/**
* Dubbo Spring Cloud Consumer Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration
@@ -60,10 +62,10 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@EnableCaching
public class DubboSpringCloudConsumerBootstrap {
@Reference
@DubboReference
private UserService userService;
@Reference(version = "1.0.0", protocol = "dubbo")
@DubboReference(version = "1.0.0", protocol = "dubbo")
private RestService restService;
@Autowired

View File

@@ -1,14 +1,12 @@
dubbo:
registry:
# The Spring Cloud Dubbo's registry extension
## the default value of dubbo-provider-services is "*", that means to subscribe all providers,
## thus it's optimized if subscriber specifies the required providers.
address: spring-cloud://localhost
# The traditional Dubbo's registry also is supported
# address: zookeeper://127.0.0.1:2181
cloud:
# The subscribed services in consumer side
subscribed-services: ${provider.application.name}
protocols:
dubbo:
port: -1
consumer:
check: false
consumer:
check: false

View File

@@ -8,6 +8,8 @@ spring:
# default disable all
cloud:
nacos:
username: nacos
password: nacos
discovery:
enabled: false
register-enabled: false

View File

@@ -23,6 +23,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* Dubbo Spring Cloud Provider Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

View File

@@ -20,12 +20,12 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.config.annotation.DubboService;
/**
* In-Memory {@link UserService} implementation.
*/
@Service(protocol = "dubbo")
@DubboService(protocol = "dubbo")
public class InMemoryUserService implements UserService {
private Map<Long, User> usersRepository = new HashMap<>();

View File

@@ -30,7 +30,7 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,7 +42,7 @@ import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE;
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@Service(version = "1.0.0", protocol = { "dubbo", "rest" })
@DubboService(version = "1.0.0", protocol = { "dubbo", "rest" })
@Path("/")
public class StandardRestService implements RestService {

View File

@@ -9,11 +9,6 @@ dubbo:
name: rest
port: 9090
server: netty
registry:
# The Spring Cloud Dubbo's registry extension
address: spring-cloud://localhost
# The traditional Dubbo's registry
# address: zookeeper://127.0.0.1:2181
feign:
hystrix:
enabled: true

View File

@@ -33,6 +33,7 @@ spring:
enabled: true
register-enabled: true
server-addr: 127.0.0.1:8848
ephemeral: false
---

View File

@@ -22,6 +22,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* Dubbo Spring Cloud Provider Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

View File

@@ -20,12 +20,12 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.config.annotation.DubboService;
/**
* In-Memory {@link UserService} implementation.
*/
@Service(protocol = "dubbo")
@DubboService(protocol = "dubbo")
public class InMemoryUserService implements UserService {
private Map<Long, User> usersRepository = new HashMap<>();

View File

@@ -19,7 +19,7 @@ package com.alibaba.cloud.dubbo.service;
import java.util.HashMap;
import java.util.Map;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.config.annotation.DubboService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,7 +39,7 @@ import static com.alibaba.cloud.dubbo.util.LoggerUtils.log;
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@Service(version = "1.0.0")
@DubboService(version = "1.0.0")
@RestController
public class SpringRestService implements RestService {

View File

@@ -3,16 +3,7 @@ dubbo:
base-packages: com.alibaba.cloud.dubbo.service
protocols:
dubbo:
name: dubbo
port: -1
registries:
new:
address: spring-cloud://localhost
# registry:
# The Spring Cloud Dubbo's registry extension
# address: spring-cloud://localhost
# The traditional Dubbo's registry
# address: nacos://127.0.0.1:8848
feign:
hystrix:

View File

@@ -8,6 +8,8 @@ spring:
# default disable all
cloud:
nacos:
username: nacos
password: nacos
discovery:
enabled: false
register-enabled: false

View File

@@ -17,7 +17,7 @@
package com.alibaba.cloud.dubbo.bootstrap;
import com.alibaba.cloud.dubbo.service.EchoService;
import org.apache.dubbo.config.annotation.Service;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@@ -25,6 +25,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
/**
* Dubbo Spring Cloud Server Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration
@@ -36,7 +38,7 @@ public class DubboSpringCloudServerBootstrap {
}
@Service
@DubboService
class EchoServiceImpl implements EchoService {
@Override

View File

@@ -24,6 +24,8 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* Dubbo Spring Cloud Servlet Gateway Bootstrap.
*
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
*/
@EnableDiscoveryClient
@EnableAutoConfiguration

View File

@@ -52,8 +52,8 @@ import org.springframework.util.StreamUtils;
import org.springframework.web.servlet.HttpServletBean;
import org.springframework.web.util.UriComponents;
import static org.apache.commons.lang3.StringUtils.substringAfter;
import static org.apache.commons.lang3.StringUtils.substringBetween;
import static org.apache.commons.lang.StringUtils.substringAfter;
import static org.apache.commons.lang.StringUtils.substringBetween;
import static org.springframework.web.util.UriComponentsBuilder.fromUriString;
@WebServlet(urlPatterns = "/dsc/*")

View File

@@ -20,9 +20,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
@@ -33,10 +34,6 @@
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -6,11 +6,13 @@ spring:
username: nacos
password: nacos
discovery:
server-addr: localhost:8848
server-addr: 127.0.0.1:8848
group: test
gateway:
discovery:
locator:
enabled: true
application:
name: node-service
sidecar:
@@ -18,8 +20,9 @@ sidecar:
ip: 127.0.0.1
# 异构微服务的端口
port: 8060
# 异构微服务的健康检查URL
health-check-url: http://localhost:8060/health.json
#health-check-url: http://localhost:8060/health.json
management:
endpoint:
health:

View File

@@ -13,8 +13,7 @@
<artifactId>spring-cloud-bus-rocketmq-example</artifactId>
<name>Spring Cloud Starter Bus Alibaba RocketMQ Example</name>
<description>Example demonstrating how to use Spring Cloud Bus RocketMQ</description>
<packaging>jar</packaging>
<packaging>jar</packaging>
<dependencies>