apache / apache/incubator-seata-samples

Seata与Spring Cloud Circuit Breaker同时使用时,Seata分布式事务功能失效

Open
#307 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.4k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

seata-samples中

springcloud-jpa-seata列子中添加Spring Cloud Circuit Breaker 熔断器后,导致Seata分布式事务功能失效
[(该demo中添加熔断器后的代码可直接见此处)](https://github.com/n65785828/springcloud-jpa-seata)
添加熔断操作如下:

1.pom文件中升级spring boot 与spring cloud版本(Spring Cloud Circuit Breaker 在springcloud Hoxton版本才能使用 )

`
org.springframework.cloud
spring-cloud-dependencies
Hoxton.RELEASE
pom
import


org.springframework.boot
spring-boot-dependencies
2.2.2.RELEASE
pom
import
`

2.在business-service 中引入添加Spring Cloud Circuit Breaker 及其实现 resilience4j依赖

`
org.springframework.cloud
spring-cloud-starter-circuitbreaker-resilience4j
`

3.禁用默认熔断feign.hystrix.enabled=false,在business-service io.seata.sample.service.BusinessService.class中添加熔断器

` @Service
public class BusinessService {

@Autowired
private StorageFeignClient storageFeignClient;
@Autowired
private OrderFeignClient orderFeignClient;

@Autowired
private CircuitBreakerFactory cbFactory;

/**
* 减库存,下订单
*
* @param userId
* @param commodityCode
* @param orderCount
*/
@GlobalTransactional
public void purchase(String userId, String commodityCode, int orderCount) {
cbFactory.create("CircuitBreakerName_storage").run(
new Supplier() {
@Override
public Boolean get() {
storageFeignClient.deduct(commodityCode, orderCount);
orderFeignClient.create(userId, commodityCode, orderCount);
return true;
}
}
);

}
}`
添加熔断后发现@GlobalTransactional注解失效了,无法进行全局事务的回滚。是不是seata与

Spring Cloud Circuit Breaker熔断不兼容?

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure in the springcloud-jpa-seata sample linked in the issue, then inspect its pom files and business-service's io.seata.sample.service.BusinessService class. Start by comparing the Spring Boot, Spring Cloud, Circuit Breaker, and Seata setup, and verify whether a failed remote call still rolls back the @GlobalTransactional operation; done means the incompatibility is explained and global rollback works or the limitation is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.