【问题标题】:Does Spring framework supports propagation of transaction contexts across osgi calls?Spring 框架是否支持跨 osgi 调用传播事务上下文?
【发布时间】:2017-03-15 13:14:28
【问题描述】:

我在不同的 OSGI 包中都有用 @Transactional 注释的方法。所有的bundles都使用了spring提供的自己的事务管理器。现在,如果我使用 bundle1 和 bundle2 的 OSGI 引用在 bundle3 中调用 methodA() 和 methodB(),它会包含在单个事务中吗?那么,如果 methodB() 失败,是否应该回滚 methodA() 呢?

捆绑1

 class ServiceA {
    @Transactional
    public void methodA() {
       ..........
    }
}

捆绑包2

class ServiceB {
    @Transactional
    public void methodB() {
       ..........
    }
}

捆绑3

 class ServiceC {
    @Autowired
    Bundle1 b1;

    @Autowired
    Bundle2 b2;

    @Transactional
    public void methodC() {
           b1.methodA();
           b2.methodB();
        }
    }

【问题讨论】:

    标签: java spring spring-mvc transactions osgi


    【解决方案1】:

    Spring 使用本地线程来存储事务上下文。由于 OSGi 服务调用使用相同的线程,我认为应该传播事务。

    【讨论】:

      猜你喜欢
      • 2011-09-20
      • 1970-01-01
      • 2019-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多