users@glassfish.java.net

JCA question regarding transactions

From: <glassfish_at_javadesktop.org>
Date: Fri, 11 Jun 2010 18:23:39 PDT

I've written a Drools resource adapter so that Drools--with all of its file-centric activity, which is expressly prohibited by the EJB specification--can be accessed from an EJB.

I have marked that this resource adapter does not support transactions, since for the moment I simply care about StatelessKnowledgeSessions, and there is nothing persistent about the actual rules engine in any case.

But now it occurs to me: it is perfectly legal for the caller of this to hand it an EntityManager (or anything else, really) as a kind of scripting/global variable. Consequently, some of the rules' actions may be to invoke operations on the supplied EntityManager.

If this all happens when the JCA adapter is called by an EJB that has joined a transaction--what is the behavior?

Will the calling EJB's transaction be suspended? Or does the "nope, this resource adapter doesn't support transactions" simply mean that no extra XA magic happens (that is, if a transaction is currently in process it will continue to be in process even after the interaction with the RA is complete?

Obviously I would like it to be the case that if the EJB is in a transaction, and if the rules engine operates on an EntityManager that the EJB supplies to it, then I want the persistence operations that the rules engine makes to be committed in the EJB's transaction. Does this mean that I'm actually going to have to investigate how to make a resource adapter work with transactions, or does declaring that it does NOT support transactions really just mean that it doesn't do anything special with them?

Thanks,
Laird
[Message sent by forum member 'ljnelson']

http://forums.java.net/jive/thread.jspa?messageID=473981