- I have an EJB method method A () that is annotated with a transparency attribute. REQUIRES_NEW
- Method A () calls two EJB methods (methodB (), methodC ()) that are running on a remote server
- methodB () does some database inserts The law is also annotated with the transaction attribute. REQUIRED
- methodC () which is annotated with the transaction attribute. REQUIRED and I'm throwing some runtime exceptions to test it for transaction management.
- When I tested my MethodA for transaction management, I saw the following
in the OpenEJB log,
-
Texas Requires_New: No suspension of transaction.
-
Texas Requires_New: Start Transactions ... gerenimo TransactionImpl ....
-
Complete the log from the methodB exec ... Does.
-
MethodC throws some RuntimeException
-
Texas Requires_New: Rolling Back Transaction ...
============
Although it states that the transaction is being reverted. Database saved through database AA () Records still appear in the database. I would like that database inserts should also be rolled back.
Would you please help me understand what is wrong?
The problem is that the methods A, B, and C are running in different transaction codes, so In your process, there are three separate and independent transactions executed in isolation.
Each appserver defines a transaction-related context in which it is shared by EJBs positioned in the same server.
When you make a call while running an EJB in a remote server, the current transaction is not done.
If you want to share the same transaction on a different remote server, then you have to implement a distributed transaction.
-
No comments:
Post a Comment