commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marián Macik <mma...@redhat.com>
Subject [dbcp] Narayana with DBCP using XADataSource
Date Wed, 25 Oct 2017 08:57:20 GMT
Hello,

I am trying to use Narayana transaction manager with Apache Commons
DBCP. The issue is that I would like to use XA DataSource and there is a
very small amount of documentation about how to set DBCP with XA. From
what I read I understood that I should probably use
BasicManagedDataSource instead of BasicDataSource, which is only for
non-XA connections, right?

The other thing is that now I have 3 options according to
https://github.com/apache/commons-dbcp/blob/master/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java#L135

1. Use ordinary driverClassName from BasicDataSource - it will create
non-XA connection factory which is then wrapped by xaConnectionFactory.

2. Set xaDataSource which is of type String - so I will provide e.g.
oracle.jdbc.xa.client.OracleXADataSource and then if I haven't created
instance myself it will be created for me inside createConnectionFactory
method.

Here the biggest question is - How then I provide/set e.g. URL to the
data source if it is created without any additional calls in the middle
of the initialization of whole DBCP - I cannot call
getXaDataSourceInstance and call setUrl myself because the DBCP will
have been already initialized by then. User and password are obtained
via getUser/getPassword methods, so this is OK. GetUrl method is used
only inside BasicDataSource and it is not used on xaDataSource instance.

3. Create oracle.jdbc.xa.client.OracleXADataSource myself, call methods
I want to call on it and set it on the BasicManagedDataSource.


After that I guess I just need to set Narayana TransactionManager via
BasicManagedDataSource.setTransactionManager method and I should be good
to go, right?


Thank you very much for answers. The biggest question for me is the
point no. 2 - if DBCP creates XADataSource for me automatically - where
does it set the URL, driverType and other properties in case they are
needed? At least the URL is mandatory.

Best regards,

Marian Macik



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message