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

sync code

This commit is contained in:
flystar32 2019-06-03 14:45:31 +08:00
parent 2dc4061c58
commit 508f0f864e
26 changed files with 223 additions and 181 deletions

View File

@ -18,19 +18,19 @@
<properties> <properties>
<sentinel.version>1.6.1</sentinel.version> <sentinel.version>1.6.1</sentinel.version>
<oss.version>3.1.0</oss.version> <oss.version>3.1.0</oss.version>
<seata.version>0.5.1</seata.version>
<nacos.version>1.0.0</nacos.version> <nacos.version>1.0.0</nacos.version>
<fescar.version>0.4.2</fescar.version> <acm.version>1.0.9</acm.version>
<acm.version>1.0.8</acm.version>
<ans.version>1.0.1</ans.version> <ans.version>1.0.1</ans.version>
<aliyun.sdk.version>4.0.1</aliyun.sdk.version> <aliyun.sdk.version>4.4.1</aliyun.sdk.version>
<alicloud.context.version>1.0.5</alicloud.context.version> <alicloud.context.version>1.0.5</alicloud.context.version>
<aliyun.sdk.edas.version>2.16.0</aliyun.sdk.edas.version> <aliyun.sdk.edas.version>2.44.0</aliyun.sdk.edas.version>
<rocketmq.starter.version>2.0.2</rocketmq.starter.version> <rocketmq.starter.version>2.0.2</rocketmq.starter.version>
<schedulerX.client.version>2.1.6</schedulerX.client.version> <schedulerX.client.version>2.1.6</schedulerX.client.version>
<aliyun.java.sdk.dysmsapi>1.1.0</aliyun.java.sdk.dysmsapi>
<aliyun.sdk.mns>1.1.8</aliyun.sdk.mns>
<dubbo.version>2.7.1</dubbo.version> <dubbo.version>2.7.1</dubbo.version>
<dubbo-spring-boot.version>2.7.1</dubbo-spring-boot.version> <dubbo-spring-boot.version>2.7.1</dubbo-spring-boot.version>
<aliyun.java.sdk.dysmsapi>1.1.0</aliyun.java.sdk.dysmsapi>
<aliyun.sdk.mns>1.1.8.6</aliyun.sdk.mns>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
@ -191,9 +191,9 @@
<!--Alibaba Fescar--> <!--Alibaba Fescar-->
<dependency> <dependency>
<groupId>com.alibaba.fescar</groupId> <groupId>io.seata</groupId>
<artifactId>fescar-spring</artifactId> <artifactId>seata-spring</artifactId>
<version>${fescar.version}</version> <version>${seata.version}</version>
</dependency> </dependency>
<!-- Dubbo --> <!-- Dubbo -->

View File

@ -17,8 +17,7 @@ package org.springframework.cloud.alibaba.cloud.examples;
import java.util.Random; import java.util.Random;
import com.alibaba.fescar.core.context.RootContext; import io.seata.core.context.RootContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;

View File

@ -16,8 +16,10 @@
package org.springframework.cloud.alibaba.cloud.examples; package org.springframework.cloud.alibaba.cloud.examples;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Random;
import com.alibaba.druid.pool.DruidDataSource;
import io.seata.rm.datasource.DataSourceProxy;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -25,9 +27,6 @@ import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fescar.rm.datasource.DataSourceProxy;
/** /**
* @author xiaojing * @author xiaojing
*/ */

View File

@ -16,8 +16,7 @@
package org.springframework.cloud.alibaba.cloud.examples; package org.springframework.cloud.alibaba.cloud.examples;
import com.alibaba.fescar.spring.annotation.GlobalTransactional; import io.seata.spring.annotation.GlobalTransactional;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.cloud.alibaba.cloud.examples.BusinessApplication.OrderService; import org.springframework.cloud.alibaba.cloud.examples.BusinessApplication.OrderService;

View File

@ -20,15 +20,35 @@ transport {
worker-thread-size = 8 worker-thread-size = 8
} }
} }
## transaction log store
store { store {
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions ## store mode: file、db
max-branch-session-size = 16384 mode = "file"
# globe session size , if exceeded throws exceptions
max-global-session-size = 512 ## file store
# file buffer size , if exceeded allocate new buffer file {
file-write-buffer-cache-size = 16384 dir = "sessionStore"
# when recover batch read size
session.reload.read_size = 100 # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max-branch-session-size = 16384
# globe session size , if exceeded throws exceptions
max-global-session-size = 512
# file buffer size , if exceeded allocate new buffer
file-write-buffer-cache-size = 16384
# when recover batch read size
session.reload.read_size = 100
# async, sync
flush-disk-mode = async
}
## database store
db {
driver_class = ""
url = ""
user = ""
password = ""
}
} }
service { service {
#vgroup->rgroup #vgroup->rgroup

View File

@ -1,5 +1,5 @@
registry { registry {
# file 、nacos 、eureka、redis、zk、consul # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file" type = "file"
nacos { nacos {
@ -26,6 +26,19 @@ registry {
cluster = "default" cluster = "default"
serverAddr = "127.0.0.1:8500" 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 { file {
name = "file.conf" name = "file.conf"
} }
@ -41,7 +54,7 @@ config {
cluster = "default" cluster = "default"
} }
apollo { apollo {
app.id = "fescar-server" app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801" apollo.meta = "http://192.168.1.204:8801"
} }
zk { zk {

View File

@ -25,7 +25,7 @@ import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fescar.rm.datasource.DataSourceProxy; import io.seata.rm.datasource.DataSourceProxy;
/** /**
* @author xiaojing * @author xiaojing

View File

@ -16,8 +16,8 @@
package org.springframework.cloud.alibaba.cloud.examples; package org.springframework.cloud.alibaba.cloud.examples;
import com.alibaba.fescar.core.context.RootContext;
import io.seata.core.context.RootContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;

View File

@ -20,15 +20,35 @@ transport {
worker-thread-size = 8 worker-thread-size = 8
} }
} }
## transaction log store
store { store {
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions ## store mode: file、db
max-branch-session-size = 16384 mode = "file"
# globe session size , if exceeded throws exceptions
max-global-session-size = 512 ## file store
# file buffer size , if exceeded allocate new buffer file {
file-write-buffer-cache-size = 16384 dir = "sessionStore"
# when recover batch read size
session.reload.read_size = 100 # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max-branch-session-size = 16384
# globe session size , if exceeded throws exceptions
max-global-session-size = 512
# file buffer size , if exceeded allocate new buffer
file-write-buffer-cache-size = 16384
# when recover batch read size
session.reload.read_size = 100
# async, sync
flush-disk-mode = async
}
## database store
db {
driver_class = ""
url = ""
user = ""
password = ""
}
} }
service { service {
#vgroup->rgroup #vgroup->rgroup

View File

@ -1,5 +1,5 @@
registry { registry {
# file 、nacos 、eureka、redis、zk、consul # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file" type = "file"
nacos { nacos {
@ -26,6 +26,19 @@ registry {
cluster = "default" cluster = "default"
serverAddr = "127.0.0.1:8500" 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 { file {
name = "file.conf" name = "file.conf"
} }
@ -41,7 +54,7 @@ config {
cluster = "default" cluster = "default"
} }
apollo { apollo {
app.id = "fescar-server" app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801" apollo.meta = "http://192.168.1.204:8801"
} }
zk { zk {

View File

@ -19,14 +19,14 @@
1. 创建 示例中 业务所需要的数据库表 1. 创建 示例中 业务所需要的数据库表
1. 启动 Fescar Server 1. 启动 Seata Server
### 配置数据库 ### 配置数据库
首先,你需要有一个支持 InnoDB 引擎的 MySQL 数据库。 首先,你需要有一个支持 InnoDB 引擎的 MySQL 数据库。
**注意** 实际上,Fescar 支持不同的应用使用完全不相干的数据库,但是这里为了简单地演示一个原理,所以我们选择了只使用一个数据库。 **注意** 实际上,Seata 支持不同的应用使用完全不相干的数据库,但是这里为了简单地演示一个原理,所以我们选择了只使用一个数据库。
`account-server``order-service``storage-service` 这三个应用中的 resources 目录下的 `application.properties` 文件中的如下配置修改成你运行环境中的实际配置。 `account-server``order-service``storage-service` 这三个应用中的 resources 目录下的 `application.properties` 文件中的如下配置修改成你运行环境中的实际配置。
@ -42,7 +42,7 @@ mysql.user.password=your mysql server password
### 创建 undo_log 表 ### 创建 undo_log 表
[Fescar AT 模式]() 需要使用到 undo_log 表。 [Seata AT 模式]() 需要使用到 undo_log 表。
``` $sql ``` $sql
-- 注意此处0.3.0+ 增加唯一索引 ux_undo_log -- 注意此处0.3.0+ 增加唯一索引 ux_undo_log
@ -93,24 +93,24 @@ CREATE TABLE `account_tbl` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
``` ```
### 启动 Fescar Server ### 启动 Seata Server
点击这个页面 [https://github.com/alibaba/fescar/releases](https://github.com/alibaba/fescar/releases),下载最新版本的 Fescar Server 端. 点击这个页面 [https://github.com/seata/seata/releases](https://github.com/seata/seata/releases),下载最新版本的 Seata Server 端.
进入解压之后的 bin 目录,执行如下命令来启动 进入解压之后的 bin 目录,执行如下命令来启动
```$shell ```$shell
sh fescar-server.sh $LISTEN_PORT $PATH_FOR_PERSISTENT_DATA sh seata-server.sh $LISTEN_PORT $MODE(file or db)
``` ```
在这个示例中,采用如下命令来启动 Fescar Server 在这个示例中,采用如下命令来启动 Seata Server
```$shell ```$shell
sh fescar-server.sh 8091 ~/fescar/data/ sh seata-server.sh 8091 file
``` ```
**注意** 如果你修改了端口号,那么记得需要在各个示例工程中的 `application.conf` 文件中,修改 grouplist 的值 **注意** 如果你修改了endpoint且注册中心使用默认file类型那么记得需要在各个示例工程中的 `file.conf` 文件中,修改 grouplist 的值(当registry.conf 中registry.type 或 config.type 为file 时会读取内部的file节点中的文件名若type不为file将直接从配置类型的对应元数据的注册配置中心读取数据),推荐大家使用 nacos 作为配置注册中心
## 运行示例 ## 运行示例
@ -146,12 +146,12 @@ http://127.0.0.1:18081/fescar/rest
## 对 Spring Cloud 支持点 ## 对 Spring Cloud 支持点
- 通过 Spring MVC 提供服务的服务提供者,在收到 header 中含有 Fescar 信息的 HTTP 请求时,可以自动还原 Fescar 上下文。 - 通过 Spring MVC 提供服务的服务提供者,在收到 header 中含有 Seata 信息的 HTTP 请求时,可以自动还原 Seata 上下文。
- 支持服务调用者通过 RestTemplate 调用时,自动传递 Fescar 上下文。 - 支持服务调用者通过 RestTemplate 调用时,自动传递 Seata 上下文。
- 支持服务调用者通过 FeignClient 调用时,自动传递 Fescar 上下文。 - 支持服务调用者通过 FeignClient 调用时,自动传递 Seata 上下文。
- 支持 FeignClient 和 Hystrix 同时使用的场景。 - 支持 SeataClient 和 Hystrix 同时使用的场景。
- 支持 FeignClient 和 Sentinel 同时使用的场景。 - 支持 SeataClient 和 Sentinel 同时使用的场景。

View File

@ -19,7 +19,7 @@ package org.springframework.cloud.alibaba.cloud.examples;
import java.sql.SQLException; import java.sql.SQLException;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fescar.rm.datasource.DataSourceProxy; import io.seata.rm.datasource.DataSourceProxy;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;

View File

@ -16,7 +16,7 @@
package org.springframework.cloud.alibaba.cloud.examples; package org.springframework.cloud.alibaba.cloud.examples;
import com.alibaba.fescar.core.context.RootContext; import io.seata.core.context.RootContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -20,15 +20,35 @@ transport {
worker-thread-size = 8 worker-thread-size = 8
} }
} }
## transaction log store
store { store {
# branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions ## store mode: file、db
max-branch-session-size = 16384 mode = "file"
# globe session size , if exceeded throws exceptions
max-global-session-size = 512 ## file store
# file buffer size , if exceeded allocate new buffer file {
file-write-buffer-cache-size = 16384 dir = "sessionStore"
# when recover batch read size
session.reload.read_size = 100 # branch session size , if exceeded first try compress lockkey, still exceeded throws exceptions
max-branch-session-size = 16384
# globe session size , if exceeded throws exceptions
max-global-session-size = 512
# file buffer size , if exceeded allocate new buffer
file-write-buffer-cache-size = 16384
# when recover batch read size
session.reload.read_size = 100
# async, sync
flush-disk-mode = async
}
## database store
db {
driver_class = ""
url = ""
user = ""
password = ""
}
} }
service { service {
#vgroup->rgroup #vgroup->rgroup

View File

@ -1,5 +1,5 @@
registry { registry {
# file 、nacos 、eureka、redis、zk、consul # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
type = "file" type = "file"
nacos { nacos {
@ -26,6 +26,19 @@ registry {
cluster = "default" cluster = "default"
serverAddr = "127.0.0.1:8500" 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 { file {
name = "file.conf" name = "file.conf"
} }
@ -41,7 +54,7 @@ config {
cluster = "default" cluster = "default"
} }
apollo { apollo {
app.id = "fescar-server" app.id = "seata-server"
apollo.meta = "http://192.168.1.204:8801" apollo.meta = "http://192.168.1.204:8801"
} }
zk { zk {

View File

@ -123,61 +123,10 @@ public class NacosWatch implements ApplicationEventPublisherAware, SmartLifecycl
} }
public void nacosServicesWatch() { public void nacosServicesWatch() {
try {
boolean changed = false; // nacos doesn't support watch now , publish an event every 30 seconds.
NamingService namingService = properties.namingServiceInstance(); this.publisher.publishEvent(
new HeartbeatEvent(this, nacosWatchIndex.getAndIncrement()));
ListView<String> listView = properties.namingServiceInstance()
.getServicesOfServer(1, Integer.MAX_VALUE);
List<String> serviceList = listView.getData();
// if there are new services found, publish event
Set<String> currentServices = new HashSet<>(serviceList);
currentServices.removeAll(cacheServices);
if (currentServices.size() > 0) {
changed = true;
}
// if some services disappear, publish event
if (cacheServices.removeAll(new HashSet<>(serviceList))
&& cacheServices.size() > 0) {
changed = true;
for (String serviceName : cacheServices) {
namingService.unsubscribe(serviceName,
subscribeListeners.get(serviceName));
subscribeListeners.remove(serviceName);
}
}
cacheServices = new HashSet<>(serviceList);
// subscribe services's node change, publish event if nodes changed
for (String serviceName : cacheServices) {
if (!subscribeListeners.containsKey(serviceName)) {
EventListener eventListener = new EventListener() {
@Override
public void onEvent(Event event) {
NacosWatch.this.publisher.publishEvent(new HeartbeatEvent(
NacosWatch.this, nacosWatchIndex.getAndIncrement()));
}
};
subscribeListeners.put(serviceName, eventListener);
namingService.subscribe(serviceName, eventListener);
}
}
if (changed) {
this.publisher.publishEvent(
new HeartbeatEvent(this, nacosWatchIndex.getAndIncrement()));
}
}
catch (Exception e) {
log.error("Error watching Nacos Service change", e);
}
} }
} }

View File

@ -16,8 +16,8 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.alibaba.fescar</groupId> <groupId>io.seata</groupId>
<artifactId>fescar-spring</artifactId> <artifactId>seata-spring</artifactId>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -16,7 +16,7 @@
package org.springframework.cloud.alibaba.seata; package org.springframework.cloud.alibaba.seata;
import com.alibaba.fescar.spring.annotation.GlobalTransactionScanner; import io.seata.spring.annotation.GlobalTransactionScanner;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;

View File

@ -27,7 +27,7 @@ public class SeataProperties {
// todo support config Fescar server information // todo support config Fescar server information
/** /**
* Fescar tx service group.default is ${spring.application.name}-fescar-service-group. * Seata tx service group.default is ${spring.application.name}-fescar-service-group.
*/ */
private String txServiceGroup; private String txServiceGroup;

View File

@ -23,13 +23,11 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.alibaba.fescar.core.context.RootContext;
import org.springframework.beans.factory.BeanFactory;
import feign.Client; import feign.Client;
import feign.Request; import feign.Request;
import feign.Response; import feign.Response;
import io.seata.core.context.RootContext;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -37,49 +35,49 @@ import org.springframework.util.StringUtils;
*/ */
public class SeataFeignClient implements Client { public class SeataFeignClient implements Client {
private final Client delegate; private final Client delegate;
private final BeanFactory beanFactory; private final BeanFactory beanFactory;
private static final int MAP_SIZE = 16;
SeataFeignClient(BeanFactory beanFactory) { SeataFeignClient(BeanFactory beanFactory) {
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
this.delegate = new Client.Default(null, null); this.delegate = new Client.Default(null, null);
} }
SeataFeignClient(BeanFactory beanFactory, Client delegate) { SeataFeignClient(BeanFactory beanFactory, Client delegate) {
this.delegate = delegate; this.delegate = delegate;
this.beanFactory = beanFactory; this.beanFactory = beanFactory;
} }
@Override @Override
public Response execute(Request request, Request.Options options) throws IOException { public Response execute(Request request, Request.Options options) throws IOException {
Request modifiedRequest = getModifyRequest(request); Request modifiedRequest = getModifyRequest(request);
try { try {
return this.delegate.execute(modifiedRequest, options); return this.delegate.execute(modifiedRequest, options);
} } finally {
finally {
} }
} }
private Request getModifyRequest(Request request) { private Request getModifyRequest(Request request) {
String xid = RootContext.getXID(); String xid = RootContext.getXID();
if (StringUtils.isEmpty(xid)) { if (StringUtils.isEmpty(xid)) {
return request; return request;
} }
Map<String, Collection<String>> headers = new HashMap<>(); Map<String, Collection<String>> headers = new HashMap<>(MAP_SIZE);
headers.putAll(request.headers()); headers.putAll(request.headers());
List<String> fescarXid = new ArrayList<>(); List<String> fescarXid = new ArrayList<>();
fescarXid.add(xid); fescarXid.add(xid);
headers.put(RootContext.KEY_XID, fescarXid); headers.put(RootContext.KEY_XID, fescarXid);
return Request.create(request.method(), request.url(), headers, request.body(), return Request.create(request.method(), request.url(), headers, request.body(),
request.charset()); request.charset());
} }
} }

View File

@ -65,19 +65,19 @@ public class SeataFeignClientAutoConfiguration {
protected static class FeignBeanPostProcessorConfiguration { protected static class FeignBeanPostProcessorConfiguration {
@Bean @Bean
SeataBeanPostProcessor fescarBeanPostProcessor( SeataBeanPostProcessor seataBeanPostProcessor(
SeataFeignObjectWrapper seataFeignObjectWrapper) { SeataFeignObjectWrapper seataFeignObjectWrapper) {
return new SeataBeanPostProcessor(seataFeignObjectWrapper); return new SeataBeanPostProcessor(seataFeignObjectWrapper);
} }
@Bean @Bean
SeataContextBeanPostProcessor fescarContextBeanPostProcessor( SeataContextBeanPostProcessor seataContextBeanPostProcessor(
BeanFactory beanFactory) { BeanFactory beanFactory) {
return new SeataContextBeanPostProcessor(beanFactory); return new SeataContextBeanPostProcessor(beanFactory);
} }
@Bean @Bean
SeataFeignObjectWrapper fescarFeignObjectWrapper(BeanFactory beanFactory) { SeataFeignObjectWrapper seataFeignObjectWrapper(BeanFactory beanFactory) {
return new SeataFeignObjectWrapper(beanFactory); return new SeataFeignObjectWrapper(beanFactory);
} }
} }

View File

@ -30,7 +30,7 @@ import com.netflix.hystrix.HystrixCommand;
public class SeataHystrixAutoConfiguration { public class SeataHystrixAutoConfiguration {
@Bean @Bean
SeataHystrixConcurrencyStrategy fescarHystrixConcurrencyStrategy() { SeataHystrixConcurrencyStrategy seataHystrixConcurrencyStrategy() {
return new SeataHystrixConcurrencyStrategy(); return new SeataHystrixConcurrencyStrategy();
} }

View File

@ -17,7 +17,7 @@ package org.springframework.cloud.alibaba.seata.feign.hystrix;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import com.alibaba.fescar.core.context.RootContext; import io.seata.core.context.RootContext;
import com.netflix.hystrix.strategy.HystrixPlugins; import com.netflix.hystrix.strategy.HystrixPlugins;
import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy; import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;
@ -37,7 +37,7 @@ public class SeataHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy
@Override @Override
public <K> Callable<K> wrapCallable(Callable<K> c) { public <K> Callable<K> wrapCallable(Callable<K> c) {
if (c instanceof FescarContextCallable) { if (c instanceof SeataContextCallable) {
return c; return c;
} }
@ -48,19 +48,19 @@ public class SeataHystrixConcurrencyStrategy extends HystrixConcurrencyStrategy
else { else {
wrappedCallable = c; wrappedCallable = c;
} }
if (wrappedCallable instanceof FescarContextCallable) { if (wrappedCallable instanceof SeataContextCallable) {
return wrappedCallable; return wrappedCallable;
} }
return new FescarContextCallable<>(wrappedCallable); return new SeataContextCallable<>(wrappedCallable);
} }
private static class FescarContextCallable<K> implements Callable<K> { private static class SeataContextCallable<K> implements Callable<K> {
private final Callable<K> actual; private final Callable<K> actual;
private final String xid; private final String xid;
FescarContextCallable(Callable<K> actual) { SeataContextCallable(Callable<K> actual) {
this.actual = actual; this.actual = actual;
this.xid = RootContext.getXID(); this.xid = RootContext.getXID();
} }

View File

@ -31,18 +31,17 @@
package org.springframework.cloud.alibaba.seata.rest; package org.springframework.cloud.alibaba.seata.rest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/** /**
* @author xiaojing * @author xiaojing
*/ */
@ -51,7 +50,7 @@ import org.springframework.web.client.RestTemplate;
public class SeataRestTemplateAutoConfiguration { public class SeataRestTemplateAutoConfiguration {
@Bean @Bean
public SeataRestTemplateInterceptor fescarRestTemplateInterceptor() { public SeataRestTemplateInterceptor seataRestTemplateInterceptor() {
return new SeataRestTemplateInterceptor(); return new SeataRestTemplateInterceptor();
} }

View File

@ -18,7 +18,7 @@ package org.springframework.cloud.alibaba.seata.rest;
import java.io.IOException; import java.io.IOException;
import com.alibaba.fescar.core.context.RootContext; import io.seata.core.context.RootContext;
import org.springframework.http.HttpRequest; import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution; import org.springframework.http.client.ClientHttpRequestExecution;

View File

@ -19,7 +19,7 @@ package org.springframework.cloud.alibaba.seata.web;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.alibaba.fescar.core.context.RootContext; import io.seata.core.context.RootContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -30,10 +30,10 @@ import org.springframework.web.servlet.ModelAndView;
/** /**
* @author xiaojing * @author xiaojing
* *
* Fescar HandlerInterceptor, Convert Fescar information into * Seata HandlerInterceptor, Convert Seata information into
* @see com.alibaba.fescar.core.context.RootContext from http request's header in * @see io.seata.core.context.RootContext from http request's header in
* {@link org.springframework.web.servlet.HandlerInterceptor#preHandle(HttpServletRequest , HttpServletResponse , Object )}, * {@link org.springframework.web.servlet.HandlerInterceptor#preHandle(HttpServletRequest , HttpServletResponse , Object )},
* And clean up Fescar information after servlet method invocation in * And clean up Seata information after servlet method invocation in
* {@link org.springframework.web.servlet.HandlerInterceptor#afterCompletion(HttpServletRequest, HttpServletResponse, Object, Exception)} * {@link org.springframework.web.servlet.HandlerInterceptor#afterCompletion(HttpServletRequest, HttpServletResponse, Object, Exception)}
*/ */
public class SeataHandlerInterceptor implements HandlerInterceptor { public class SeataHandlerInterceptor implements HandlerInterceptor {