异步ejb方法调用中的事务传播 [英] Transaction propagation in asynchronous ejb method call

查看:235
本文介绍了异步ejb方法调用中的事务传播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个EJB会话bean,如下所示:

We have two EJB session beans as given below;

@Stateless
public class MyStatelessSessionBean{
      @EJB
       MyStatefulSessionBean statefulBean;
      public void methodA(){
          statefulBea.methodB();
      }
}

@Stateful
@ TransactionAttribute(TransactionAttributeType.REQUIRED)
public class MyStatefulSessionBean {
     @Asynchronous
     public void methodB(){
     }

}

(不在任何事务中)调用MyStatelessSessionBean的methodA。所有处理完成后,集装箱将开始多少次交易?

A client, which is not in any in any transaction, invoke methodA of MyStatelessSessionBean. How many distict transactions will be started by container after all processing has completed ?

推荐答案

开始有2笔交易。由于EJB 3.1规范在4.5.3节中说明:

There will be 2 transactions started. As EJB 3.1 specification states in point 4.5.3:


客户端事务上下文不会通过异步方法调用传播。从Bean开发者的角度来看,客户端从来没有一个事务上下文流入。这意味着,例如,异步方法上REQUIRED事务属性的语义与REQUIRES_NEW完全相同。

Client transaction context does not propagate with an asynchronous method invocation. From the Bean Developer’s view, there is never a transaction context flowing in from the client. This means, for example, that the semantics of the REQUIRED transaction attribute on an asynchronous method are exactly the same as REQUIRES_NEW.

这篇关于异步ejb方法调用中的事务传播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆