geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Jencks <david_jen...@yahoo.com>
Subject Re: client managed distributed transactions
Date Sat, 09 May 2009 00:14:47 GMT

On May 8, 2009, at 4:20 PM, Diego Munguia wrote:

> Hi,
>
> I have a spring-based application that connects to a local database  
> and to a set of remote EJBs that are deployed on a Geronimo 2.1.4  
> server. I'm trying to configure a transaction manager that handles  
> distributed transactions, because on a single service method I may  
> have calls to the local db and to one or more EJBs (stateless  
> session beans).

I don't understand your configuration.  Is the spring app running in  
the same geronimo 2.1.4 instance as the ejbs?  If so I suspect you  
don't need to do anything so long as your ejbs are not configured to  
start new txs.  You might possibly need to use a local ejb interface,  
but I doubt it.

If your spring app is running in a different jvm than geronimo, you  
will have to do some serious coding to get this to work.  Although  
geronimo does support importing transactions through the j2ca work  
manager stuff, we don't have a full distributed transaction  
implementation.

Be sure you understand the difference between 2-phase multi-resource  
xa transactions that occur entirely in one vm (at least all the  
XAResource implementations are in the same vm) and a true distributed  
transaction in which XAResources are present in several vms; in a  
typical xa implementation of a distributed tx system you'll have at  
least two app server instances, one server will control the tx, and  
all the other servers will be represented as XAResources to the  
controlling server.

So far I've never found anyone who thinks using distributed  
transactions in a production system is plausible if there is any kind  
of load involved.  This has driven our lack of implementation.

>
>
> I've managed to configure distributed transactions in the past using  
> Jencks and the Geronimo TM but for local datasources (1 mysql db and  
> 1 jackrabbit repository), this configuration required the use of a  
> UserTransaction object, I used spring's jndi mock functionality as I  
> wasn't using a j2ee server.
??? Where did the UserTransaction come from
>
>
> I'm trying to replicate this conf on my current app but my problem  
> is that I can't get a hold of the remote UserTransaction object via  
> jndi. This is how I'm trying to retrieve it:
>
>        Properties properties = new Properties();
>        properties.put(Context.INITIAL_CONTEXT_FACTORY,  
> "org.apache.openejb.client.RemoteInitialContextFactory");
>        properties.put("java.naming.provider.url", "ejbd://localhost: 
> 4201");
>        Context context = new InitialContext(properties);
>        context.lookup("java:comp/UserTransaction");
>
> I'm getting this exception:
>
> Exception in thread "main" javax.naming.NameNotFoundException: comp/ 
> UserTransaction does not exist in the system.  Check that the app  
> was successfully deployed.
> 	at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:277)
> 	at javax.naming.InitialContext.lookup(InitialContext.java:351)


I don't understand what you want to use the UserTransaction for.  To  
control the entire jta tx or to control the ejb's participation in the  
tx?

If the latter, even if this appeared to work, it wouldn't give you a  
transaction.  UserTransaction doesn't support the 2 phase commit  
process you need for a multi-resource transaction.  IIRC spring  
doesn't make much effort to point this out.

>
>
>
> If I go to the Geronimo console and look for UserTransaction using  
> the JNDI Viewer I see that there is an user transaction object under  
> the name java:comp/UserTransaction, so I'm guessing I'm using the  
> correct jndi name on my code. Plus the app successfully retrieves  
> the ejb proxies so I know the jndi service is up and running.
>
> How can I retrieve the user transaction then? If there's a reason  
> why the user transaction is not provided for remote clients then  
> does anybody knows of an alternative strategy to do client-managed  
> transactions or any other kind of distributed transactions strategy  
> that allows me to keep track of my local db changes as well the ejbs  
> on the same transaction?

If the ejbs are on a different vm than your spring program I'd advise  
you to rethink your architecture.  If you really need them on  
different machines make the communication asynchronous using jms.

thanks
david jencks

>
>
> Thanks!
> - Diego M.


Mime
View raw message