SpringCloud + Feign 事务不回滚 解决方案
- Dominant language
- Java
- Stars
- 4.2k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
看issue发现很多人也有这个问题,我最近也碰到了,然后跟踪了一下源码,总算解决了。
下面给出我的解决步骤:
1. 打开LCN Logger
`logging.level.com.codingapi.txlcn = debug`
2. 检查日志中是否包含以下log。如包含,转6
`com.codingapi.txlcn.tracing.Tracings : tracing apply group:693a5ae3226537.....`
3. 检查日志中的各服务log中groupId是否一致 。如一致,转6
`c.c.t.t.c.context.DefaultGlobalContext : Start TxContext[693a5ae3226537]`
4. 检查是否用了 @EnableWebMvc 注解。如用了,转6
5. 添加MVC拦截器
```
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
.........其它配置省略...........
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SpringTracingApplier());
}
}
6. 结束
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the Spring Cloud and Feign transaction rollback problem described in the issue, then enable LCN debug logging and compare tracing group IDs across service logs. Check whether @EnableWebMvc is present and whether the SpringTracingApplier interceptor is registered; done means identifying and documenting the condition that prevents rollback or confirming the provided workaround.
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
- 25/100