[jboss-as7-dev] Switch to use TransactionSynchronizationRegistry.registerInterposedSynchronization?

Scott Marlow smarlow at redhat.com
Tue May 31 16:06:32 EDT 2011


We are supposed to be able to use 
TransactionSynchronizationRegistry.registerInterposedSynchronization 
(TSR) in our containers but I wanted to bring up an ordering issue that 
can happen.

If you look at http://pastie.org/1836698, you can see what happened when 
Hibernate registered a synchronization object with the TSR and we tried 
after to get a database connection from the connection pool.

Basically, once a synchronization object is registered with the TSR, the 
other way of registering a synchronization object through the 
Transaction registerSynchronization() cannot be used (or you get the 
above linked IllegalStateException error).

The short term fix was to avoid registering Hibernate with the TSR and 
instead use the Transaction registerSynchronization().  This helped 
avoid the ISE exception as the TSR sync ordering check is avoided.

The Transaction registerSynchronization(), has no ordering requirements 
but as we have seen, the TSR registerInterposedSynchronization does.

I think we need to be consistent across our projects and either use TSR 
or avoid it (to avoid the "Synchronizations are not allowed!" JTA 
error).  If/when we use it, we need to coordinate the switch over to it, 
so that all projects have time to switch to it.

I'm hoping someone will tell me that there is an easier path to use TSR 
registerInterposedSynchronization in some of our projects.  What do you 
think?

The other question, is how/when we should we coordinate a switch over to 
use TSR (assuming there is agreement that we should coordinate the switch)?

Scott


More information about the jboss-as7-dev mailing list