I recently worked a lot on jpa/jta support in OSGi. As you correctly
stated there is only very little information on this subject.
My tutorials about database access in OSGi
http://www.liquid-reality.de/pages/viewinfo.action?pageId=6586413
and camel jpa support in OSGi
http://www.liquid-reality.de/pages/viewinfo.action?pageId=7536678
should give you a first start. Unfortunately I think the camel one is
not completely correct.
I will update the tutorials shortly with what I learned recently.
Until then you can already take a look at
https://github.com/ops4j/org.ops4j.pax.jdbc
I recently added pax-jdbc-config and pax-jdbc-pool. These together will
provide you a simple way to setup
datasources without using blueprint.
One general thing in OSGi you can keep in kind is that it is a good
practice to use OSGi services to publish the jms ConnectionFactory and the
sql DataSource. This is already stated in the existing tutorials too.
What I did not know then is how to correctly handle XA
ConnectionFactories and DataSources.
I think this is the reason why I had lots of problem with my camel jpa /
jms tutorial when I tried to span an XA transaction over JMS and the DB.
What I learned now is that you need to wrap them in a special pooling
Class. So for example for activemq you need to use the
JCAPoolingConnectionFactory. See
http://cxf.apache.org/docs/jms-transactions.html
From the outside such a ConnectionFactory uses the non jta
ConnectionFactory interface.
The same is true for XADataSource. You do not use it directly but
instead wrap it into a pooling class that shows it as a DataSource to
the outside world. There dbcp2 provides the necessary pooling. The
pax-jdbc-pool code shows how to do this.
I have not yet tested the new things I learned with camel but I hope I
find the time for this soon.
Christian
Am 25.07.2014 13:20, schrieb UliSE:
Hi,
I´m trying to configure a servicemix (5.1.0) to the needs of a project I´m
in.
I´ve got some questions on database/persistence features doing so.
First: I need to connect to databases (DB2, Oracle, Mysql, postgres) using
camel-jpa (might be camel-jdbc as well)
And I sometimes need XA transactions on this
Second: I would like to change activeMQs persistence in production to a
(jdbc) database
The idea is to have reliable and clustered queues.
Surfing up an down the communities on this brings up the picture that using
a (jdbc) database is not really mainstream in OSGi environments.
If there are any samples from 3rd parties (many thanks at all) I cannot
figure out what the "servicemix way" of doing jdbc is.
The servicemix web stated, that there is support for jpa, XA, ... but for me
this is hard to setup because of missing hints (samples, ...).
Is the conclusion to use activemq/camel without servicemix or in an other
container if I want to connect to (might be several) jdbc databases?
(Would be sad, because I love OSGi and karaf.)
Is there a better way to use databases in servicemix than jdbc?
Is there a "the osgi jdbc solution for servicemix" which I can adapt for
both camel-jpa and activemq persistence?
Many thank for some information,
Uli
--
View this message in context:
http://servicemix.396122.n5.nabble.com/Database-jdbc-jpa-XA-setup-in-Servicemix-5-1-0-tp5721374.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.
--
Christian Schneider
http://www.liquid-reality.de
Open Source Architect
Talend Application Integration Division http://www.talend.com