[jboss-as7-dev] JTA Synchronization.afterCompletion callback can occur in a background thread but JPA EntityManager must be accessed in single-threaded manner...

Jason Greene jason.greene at redhat.com
Fri Feb 22 15:39:08 EST 2013


On Feb 22, 2013, at 2:38 PM, Jason Greene <jason.greene at redhat.com> wrote:

> 
> Well the problem is TX boundaries typically are the lifespan of the request, so the application thread would never fully give up control. The only thing you can really without relying on checks, or deferring to the db/tm, is to interrupt the application thread from the sync thread. However the EntityManager would have to be carefully coded to process thread interruption in a way that distinguishes between tx timeout and user requested interrupt. It's probably the same amount of code either way. 

Actually that's not a good idea, because you have no idea if the application thread is still executing the entity manager.

--
Jason T. Greene
JBoss AS Lead / EAP Platform Architect
JBoss, a division of Red Hat




More information about the jboss-as7-dev mailing list