anergy
anergy

Reputation: 1384

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 independent (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

Upvotes: 6

Views: 3352

Answers (1)

stratwine
stratwine

Reputation: 3701

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

Upvotes: 5

Related Questions