Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpringCloudSecondaryConfiguration.annotationDrivenTransactionManager()Lorg/springframework/transaction/TransactionManager; is abstract #126

Open
6westboy9 opened this issue Oct 15, 2020 · 4 comments

Comments

@6westboy9
Copy link

6westboy9 commented Oct 15, 2020

版本

spring.boot.version:2.3.2.RELEASE
spring.cloud.version:Hoxton.SR8
bytetcc-supports-springcloud.version:0.5.9

在使用 Spring Cloud 整合 ByteTCC 启动时的报错信息

2020-10-15 09:51:05.898 WARN 83254 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feignPostProcessor' defined in org.bytesoft.bytetcc.supports.springcloud.config.SpringCloudSecondaryConfiguration: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.AbstractMethodError: Method org/bytesoft/bytetcc/supports/springcloud/config/SpringCloudSecondaryConfiguration.annotationDrivenTransactionManager()Lorg/springframework/transaction/TransactionManager; is abstract

启动类

@Import(SpringCloudSecondaryConfiguration.class)
@SpringBootApplication(exclude = MongoAutoConfiguration.class) // 使用文件存储,暂不需要配置 MongoDB
public class BFAccountApplication {
    public static void main(String[] args) {
        SpringApplication.run(BFAccountApplication.class);
    }
}
@liuyangming
Copy link
Owner

你这个错误日志太少了,看不出是具体问题。不过,这类错误一般都是jar包的版本不兼容导致。

@6westboy9
Copy link
Author

你这个错误日志太少了,看不出是具体问题。不过,这类错误一般都是jar包的版本不兼容导致。

这个问题已经解决,是因为版本的问题导致

@6westboy9
Copy link
Author

1. 问题描述

现在又有一个新的问题,大概意思就是服务消费者执行后能正常 confirm,但是服务提供者并没有执行 confirm,那我现在的场景来说,订单支付成功了,但是账户服务冻结的资金也没有减掉。

2. 详细情况

2.1. 服务消费者

@Service
@Compensable(interfaceClass = PaymentService.class, simplified = true)
public class PaymentServiceImpl implements PaymentService {

    private OrderService orderService;
    private AccountClient accountClient;

    @Transactional
    @Override
    public void payment(Order order) {
        orderService.updateOrderStatus(order, OrderStatus.PAYING);
        accountClient.decrease(buildAccountPaymentDTO(order));
    }

    @CompensableConfirm
    @Transactional
    public void confirm(Order order) {
        log.info("================= PaymentService 执行 confirm 接口 =================");
        orderService.updateOrderStatus(order, OrderStatus.PAY_SUCCESS);
    }

    @CompensableCancel
    @Transactional
    public void cancel(Order order) {
        log.info("================= PaymentService 执行 cancel 接口 =================");
        orderService.updateOrderStatus(order, OrderStatus.PAY_FAIL);
    }

2.2. 服务提供者

@Service
@Compensable(interfaceClass = AccountService.class, simplified = true)
public class AccountServiceImpl implements AccountService {

    @Transactional
    @Override
    public void decrease(AccountPaymentDTO accountPaymentDTO) {
        accountMapper.decrease(accountPaymentDTO.getUserId(), accountPaymentDTO.getAmount());
    }

    @CompensableConfirm
    @Transactional
    public void confirm(AccountPaymentDTO accountPaymentDTO) {
        log.info("================= accountService 执行 confirm 接口 =================");
        accountMapper.confirmDecrease(accountPaymentDTO.getUserId(), accountPaymentDTO.getAmount());
    }

    @CompensableCancel
    @Transactional
    public void cancel(AccountPaymentDTO accountPaymentDTO) {
        log.info("================= accountService 执行 cancel 接口 =================");
        accountMapper.cancelDecrease(accountPaymentDTO.getUserId(), accountPaymentDTO.getAmount());
    }
}

3. 日志信息

3.1. 服务消费者日志

2020-10-16 14:58:29.581  INFO 61806 --- [nio-8082-exec-1] o.b.bytetcc.CompensableManagerImpl       : 6a83ba76c4d6f560b63b88013f229f99| compensable transaction begin!
2020-10-16 14:58:29.584  INFO 61806 --- [nio-8082-exec-1] o.b.bytejta.TransactionCoordinator       : 6a83ba76c4d6f560b63b88013f229f99> begin-participant
2020-10-16 14:58:29.584  INFO 61806 --- [nio-8082-exec-1] o.b.bytetcc.CompensableTransactionImpl   : 6a83ba76c4d6f560b63b88013f229f99| register compensable service: 6a83ba76c4d6f560b63b88013f229f99.
2020-10-16 14:58:29.625  INFO 61806 --- [nio-8082-exec-1] org.bytesoft.bytejta.TransactionImpl     : 6a83ba76c4d6f560b63b88013f229f99> enlist: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba76f1d6f560b63b8803529ee594, flags: 0
2020-10-16 14:58:29.628 DEBUG 61806 --- [nio-8082-exec-1] c.w.m.OrderMapper.updateOrderStatus      : ==>  Preparing: update `order` set order_status = ? where id = ? 
2020-10-16 14:58:29.629 DEBUG 61806 --- [nio-8082-exec-1] c.w.m.OrderMapper.updateOrderStatus      : ==> Parameters: 支付中(String), 39(Integer)
2020-10-16 14:58:29.631 DEBUG 61806 --- [nio-8082-exec-1] c.w.m.OrderMapper.updateOrderStatus      : <==    Updates: 1
2020-10-16 14:58:29.711  INFO 61806 --- [nio-8082-exec-1] org.bytesoft.bytejta.TransactionImpl     : 6a83ba76c4d6f560b63b88013f229f99> delist: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba76f1d6f560b63b8803529ee594, flags= 67108864
2020-10-16 14:58:29.714  INFO 61806 --- [nio-8082-exec-1] org.bytesoft.bytejta.TransactionImpl     : 6a83ba76c4d6f560b63b88013f229f99> commit-participant start
2020-10-16 14:58:29.724  INFO 61806 --- [nio-8082-exec-1] o.b.bytejta.resource.XATerminatorOptd    : 6a83ba76c4d6f560b63b88013f229f99> commit: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba76f1d6f560b63b8803529ee594, opc= false
2020-10-16 14:58:29.724  INFO 61806 --- [nio-8082-exec-1] o.b.bytetcc.CompensableTransactionImpl   : 6a83ba76c4d6f560b63b88013f229f99| try: identifier= 6a83ba76c4d6f560b63b88013f229f99, resourceKey= dataSource, resourceXid= 1207-6a83ba76c4d6f560b63b88013f229f99-6a83ba76f1d6f560b63b8803529ee594.
2020-10-16 14:58:29.725  INFO 61806 --- [nio-8082-exec-1] o.b.bytetcc.CompensableTransactionImpl   : 6a83ba76c4d6f560b63b88013f229f99| try completed.
2020-10-16 14:58:29.725  INFO 61806 --- [nio-8082-exec-1] org.bytesoft.bytejta.TransactionImpl     : 6a83ba76c4d6f560b63b88013f229f99> commit-participant complete successfully
2020-10-16 14:58:29.726  INFO 61806 --- [nio-8082-exec-1] o.b.bytejta.TransactionCoordinator       : 6a83ba76f3d6f560b63b880432120e18> begin-participant
2020-10-16 14:58:29.726  INFO 61806 --- [nio-8082-exec-1] c.w.service.impl.PaymentServiceImpl      : ================= PaymentService 执行 confirm 接口 =================
2020-10-16 14:58:29.727  INFO 61806 --- [nio-8082-exec-1] org.bytesoft.bytejta.TransactionImpl     : 6a83ba76f3d6f560b63b880432120e18> enlist: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba76c4d6f560b63b88013f229f99, flags: 0
2020-10-16 14:58:29.728 DEBUG 61806 --- [nio-8082-exec-1] c.w.m.OrderMapper.updateOrderStatus      : ==>  Preparing: update `order` set order_status = ? where id = ? 
2020-10-16 14:58:29.728 DEBUG 61806 --- [nio-8082-exec-1] c.w.m.OrderMapper.updateOrderStatus      : ==> Parameters: 支付成功(String), 39(Integer)
2020-10-16 14:58:29.730 DEBUG 61806 --- [nio-8082-exec-1] c.w.m.OrderMapper.updateOrderStatus      : <==    Updates: 1
2020-10-16 14:58:29.731  INFO 61806 --- [nio-8082-exec-1] org.bytesoft.bytejta.TransactionImpl     : 6a83ba76f3d6f560b63b880432120e18> delist: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba76c4d6f560b63b88013f229f99, flags= 67108864
2020-10-16 14:58:29.731  INFO 61806 --- [nio-8082-exec-1] org.bytesoft.bytejta.TransactionImpl     : 6a83ba76f3d6f560b63b880432120e18> commit-participant start
2020-10-16 14:58:29.737  INFO 61806 --- [nio-8082-exec-1] o.b.bytejta.resource.XATerminatorOptd    : 6a83ba76f3d6f560b63b880432120e18> commit: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba76c4d6f560b63b88013f229f99, opc= false
2020-10-16 14:58:29.737  INFO 61806 --- [nio-8082-exec-1] o.b.bytetcc.CompensableTransactionImpl   : 6a83ba76c4d6f560b63b88013f229f99| confirm: identifier= 6a83ba76c4d6f560b63b88013f229f99, resourceKey= dataSource, resourceXid= 1207-6a83ba76f3d6f560b63b880432120e18-6a83ba76c4d6f560b63b88013f229f99.
2020-10-16 14:58:29.737  INFO 61806 --- [nio-8082-exec-1] org.bytesoft.bytejta.TransactionImpl     : 6a83ba76f3d6f560b63b880432120e18> commit-participant complete successfully
2020-10-16 14:58:29.738  INFO 61806 --- [nio-8082-exec-1] o.b.bytetcc.CompensableTransactionImpl   : 6a83ba76c4d6f560b63b88013f229f99| compensable transaction committed!
2020-10-16 14:58:29.740  INFO 61806 --- [nio-8082-exec-1] o.b.bytetcc.CompensableTransactionImpl   : 6a83ba76c4d6f560b63b88013f229f99| forget transaction.

3.2. 服务提供者日志

2020-10-16 14:58:29.664  INFO 61724 --- [nio-8083-exec-3] o.b.bytetcc.CompensableCoordinator       : 6a83ba76c4d6f560b63b88013f229f99| compensable transaction begin!
2020-10-16 14:58:29.665  INFO 61724 --- [nio-8083-exec-3] o.b.bytejta.TransactionCoordinator       : 6a83ba7619d6f560b63b88052c7f741e> begin-participant
2020-10-16 14:58:29.666  INFO 61724 --- [nio-8083-exec-3] o.b.bytetcc.CompensableTransactionImpl   : 6a83ba76c4d6f560b63b88013f229f99| register compensable service: 6a83ba76c4d6f560b63b88013f229f99.
2020-10-16 14:58:29.666  INFO 61724 --- [nio-8083-exec-3] org.bytesoft.bytejta.TransactionImpl     : 6a83ba7619d6f560b63b88052c7f741e> enlist: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba761ad6f560b63b8807b569decf, flags: 0
2020-10-16 14:58:29.667 DEBUG 61724 --- [nio-8083-exec-3] c.westboy.mapper.AccountMapper.decrease  : ==>  Preparing: update account set balance = balance - ?, frozen = frozen + ? where user_id = ? and balance >= ? 
2020-10-16 14:58:29.667 DEBUG 61724 --- [nio-8083-exec-3] c.westboy.mapper.AccountMapper.decrease  : ==> Parameters: 100(Integer), 100(Integer), U000001(String), 100(Integer)
2020-10-16 14:58:29.670 DEBUG 61724 --- [nio-8083-exec-3] c.westboy.mapper.AccountMapper.decrease  : <==    Updates: 1
2020-10-16 14:58:29.670  INFO 61724 --- [nio-8083-exec-3] org.bytesoft.bytejta.TransactionImpl     : 6a83ba7619d6f560b63b88052c7f741e> delist: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba761ad6f560b63b8807b569decf, flags= 67108864
2020-10-16 14:58:29.670  INFO 61724 --- [nio-8083-exec-3] org.bytesoft.bytejta.TransactionImpl     : 6a83ba7619d6f560b63b88052c7f741e> commit-participant start
2020-10-16 14:58:29.673  INFO 61724 --- [nio-8083-exec-3] o.b.bytejta.resource.XATerminatorOptd    : 6a83ba7619d6f560b63b88052c7f741e> commit: xares= xa-res-archive[descriptor: local-xa-resource[dataSource]], branch= 6a83ba761ad6f560b63b8807b569decf, opc= false
2020-10-16 14:58:29.673  INFO 61724 --- [nio-8083-exec-3] o.b.bytetcc.CompensableTransactionImpl   : 6a83ba76c4d6f560b63b88013f229f99| try: identifier= 6a83ba76c4d6f560b63b88013f229f99, resourceKey= dataSource, resourceXid= 1207-6a83ba7619d6f560b63b88052c7f741e-6a83ba761ad6f560b63b8807b569decf.
2020-10-16 14:58:29.673  INFO 61724 --- [nio-8083-exec-3] org.bytesoft.bytejta.TransactionImpl     : 6a83ba7619d6f560b63b88052c7f741e> commit-participant complete successfully

@liuyangming
Copy link
Owner

这种情况一种可能是服务端confirm执行出错;
另外一种,也可能是服务端虽然收到了消费端传播事务上下文但自己并没有将事务上下文回传给消费方,导致消费端并没有将服务端作为一个远程分支来通知commit。具体原因可能需要你自己定位一下,相应逻辑在服务端的CompensableInterceptorImpl.beforeSendResponse() 和 消费端的CompensableInterceptorImpl.afterReceiveResponse()方法中。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants