fenixsoft / fenixsoft/monolithic_arch_springboot
事务问题
- Dominant language
- Java
- Stars
- 570
- Forks
- 324
- PR merge metrics
- No merged PRs in 30d
Description
/**
* 执行操作(带自定义的失败处理),并根据操作是否成功返回给客户端相应信息
* 封装了在服务端接口中很常见的执行操作,成功返回成功标志、失败返回失败标志的通用操作,用于简化编码
*/
public static Response op(Runnable executor, Consumer exceptionConsumer) {
try {
executor.run();
return CommonResponse.success();
} catch (Exception e) {
exceptionConsumer.accept(e);
return CommonResponse.failure(e.getMessage());
}
}
您这边使用线程执行service逻辑,
1、 首先方法会在try中执行,spring事务在执行回滚时,是捕捉运行时异常才会生效,您这样写,我不太理解
2、其次您这个方法类似于多线程执行,但是spring事务默认是在主线程中执行,没有实现跨线程,这样的代码不确定是否生效
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.