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,
- Call is no longer asynchronized.
- 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 )
精彩评论