We are in the process of upgrading from JBoss 6 to JBoss 7. The nature of our application has a separate database instance per customer, as well as a core configuration database common to all customers. We often have EJB code which will at least reference the core database plus the individual customer's data in one call, and even some general background processes that go through all customers.
In JBoss 6 this was handled without issue by setting the method with a NOT_SUPPORTED transaction attribute. However, JBoss 7 complains about this with the following error:
ARJUNA012140: Adding multiple last resources is disallowed. Trying to add LastResourceRecord(XAOnePhaseResource(LocalXAResourceImpl@74bec54d[connectionListener=d3ce980 connectionManager=25b47a05 warned=false currentXid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff0a2c28d1:-5a4c1f9a:504689c9:11, node_name=1, branch_uid=0:ffff0a2c28d1:-5a4c1f9a:504689c9:14, subordinatenodename=null, eis_name=unknown eis name >])), but already have LastResourceRecord(XAOnePhaseResource(LocalXAResourceImpl@518d0191[connectionListener=1a05d94a connectionManager=135f1cfe warned=false currentXid=< formatId=131077, gtrid_length=29, bqual_length=36, tx_uid=0:ffff0a2c28d1:-5a4c1f9a:504689c9:11, node_name=1, branch_uid=0:ffff0a2c28d1:-5a4c1f9a:504689c9:13, subordinatenodename=null, eis_name=unknown eis name >]))
How can we work around this problem without wrapping every call to the different databases in a separate EJB call and transaction. Is there a way to actually turn off the JBoss transaction management in an EJB call or something similar?
Note: This question was modified after the bounty started based on additional discovery to sharpen the focus on the specific problem and remove other possibilities that were excluded.
Two suggestions:
com.arjuna.ats.arjuna.allowMultipleLastResources
to true in the server conf. This will allow the behaviour you want, but unfortunately for the whole app, not just the method. Update:
I don't recommend enabling multiple one-phase resources since it weakens the transactional properties of you app substantially. But if you want to do this in JBoss 7 you need to modify standalone.xml
and add:
<system-properties>
<property name="com.arjuna.ats.arjuna.allowMultipleLastResources" value="true"/>
</system-properties>
You now have a system which is not far away from one without transactions. What it will still do though, is to warn you if you get heuristic outcomes.
My recommendation is still to use XA datasources if you can.
Update 2:
Oh, and if someone comes along to read this I want to add that if you can divide your code into different methods, unlike the OP, I would recommend restructuring your code and use @TransactionAttribute(REQUIRES_NEW)
to create parallel transactions. This is better than turning on multiple 1PC, albeit not as good as turning on XA.