开发者

Asynchronous EJB 3.1 methods and Transactions

I wrote a small test to understand asynchronized behavior in EJB3.1 using @Asynchronous annotation. It seems that:

If the method exist in the same bean as the caller,

  1. Call is no longer asynchronized.
  2. The caller transaction is marked for roll back, if the transaction in the asynchronous method is rolled back; its probably the side effect of 1.

However, if the asynchronous method exists in another bean, the behavior is expected i.e. call is asynchronous and the caller transaction is i开发者_开发知识库ndependent (async method have REQUIRES_NEW behavior for transaction). This is puzzling for me, as why the behavior is not the same in both cases. Would someone please clarify?

P.S. Environment EJB 3.1, JBoss 6


Calling the method using this keyword instead of using SessionContext#getBusinessObject(class) causes that. (the difference is explained here )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜