geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From munguia <diego.mung...@rbxglobal.com>
Subject Re: client managed distributed transactions
Date Tue, 12 May 2009 21:52:30 GMT

Hi David,

Thanks for your reply, let me explain in more detail the architecture I'm
currently dealing with. 

I have three spring independent applications and I have a fourth application
that need to invoke services on the other three (use them as a back-end if
you like). 

This fourth application was communicating with the other three by means of
RESTful web services, this worked pretty good until we got to a point where
a single service method in the 4th app needed to invoke a service method on
the 1st and 2nd apps, so if the call to the 1st method succeeded but the
call to the 2nd app failed then the whole setup will end up being in an
inconsistent state. 

I didn't find a solution for transactional RESTful web services, so I
decided to try an scenario where the services on the 1st, 2nd and 3rd apps
were exposed as stateless session beans. So it looks something like this
(just for the 1sp app):

VM{4th Spring App} <------> VM{Geronimo EJBs exposing 1st Spring App}

So basically we're talking about sharing a single transaction between, at
least, two different VMs. The idea will be to have the 4th app starting, an
controllling, the tx and have the other apps attaching to this tx (by means
of the REQUIRED annotation and some voodoo transaction sharing strategy =]
).

The configuration I did before had an scenario where all the action happened
inside a single VM. To answer your question the UserTransaction was just a
mock bean managed by Spring's mock JNDI functionality. I successfully
managed to share a single transaction between the two datasources (MySQL and
JCR).

Where can I find resources explaining how to import the transaction into
Geronimo (using j2ca)?

Thanks!
Diego


djencks wrote:
> 
> 
> 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.
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/client-managed-distributed-transactions-tp23455243s134p23511296.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message