|
|
distributed transactions and XA datasources!
Posted: Sun Sep 23, 2007 2:47 am Post subject: Problems with distributed transactions!
Hibernate version: 3
Spring 2 with spring JTA transaction manager
Java 1.5
Oracle 9g with XA enabled
Hi,
We have 4 lossely coupled applications that are independent except that at certain points they provide services or use services of other applications. Every application has its own database schema and uses a seperate session factory defined in its own application context. The business methods are wrapped by transactions with taget= PROPAGATION_REQUIRED. We use spring JTA transactions.The different datasources uses XA datasources. The problem that we are having is that if we invoke services of an application that uses a single datasource i.e. is own everything works fine. But if we try to invoke a service that makes calls to other applications and therefore span multiple datasources the transaction is inititated in the caller but at the point where a call to a read/write is involved to another datasource the transaction does not propagate and we get an error quot;could not invoke transaction on meta ware objectquot;--And the stack trace shows problem at OracleXAResourceManager could not start transaction. I dont know if enabling xid in jboss will serve the problem or whether we are using XA transactions propely. Our oracle server is XA enabled. We tried to switch to local datasorces and we have the same problem. Im certain that if there was only one schema and one datasource PROPAGATION_REQUIRED would have worked. Im not soure how to solve this promblem. I tried googling and came up with almost nothing. It seems to me that most people prefer to seperate the transaction boundaries instead of using distributed transactions and use something like a command pattern for undo/rollback. This means that they seperate the methods instead of having one monolethic method that spans multiple datasources. However I would like to have a go at XA datasources and distributed transactions.
Regards,
Conrad
I never used real distributed transactions so far but always stayed in one JVM and one application for accessing different data sources. Are your applications independent in sense of different JVMs or different class loaders?
I wonder (because you don't talk about it) how you propagate your transaction context. JCA might help because it knows outbound and inbound connections (at least that's what I think it's about).
Joerg
All these application are packaged into one war file and deployed in the same jboss server. The only thing is that they use different datasources and each application has its own application context and session factory. However they all share the a common transaction manager.
Originally Posted by conrad_bAll these application are packaged into one war file and deployed in the same jboss server. The only thing is that they use different datasources and each application has its own application context and session factory. However they all share the a common transaction manager.
If they don't span multiple threads then there should be no problem at all. Different data sources is just the standard use case of JTA/XA.
Joerg |
|