You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by UliSE <ul...@googlemail.com> on 2014/07/25 13:20:41 UTC

Database (jdbc, jpa, XA, ...) setup in Servicemix 5.1.0

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.

Re: Database (jdbc, jpa, XA, ...) setup in Servicemix 5.1.0

Posted by Christian Schneider <ch...@die-schneider.net>.
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


Re: Database (jdbc, jpa, XA, ...) setup in Servicemix 5.1.0

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

There is some transaction examples at Fuse by Examples
https://github.com/FuseByExample



On Fri, Jul 25, 2014 at 1:20 PM, UliSE <ul...@googlemail.com> wrote:
> 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.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/

AW: Database (jdbc, jpa, XA, ...) setup in Servicemix 5.1.0

Posted by "Walzer, Thomas" <th...@integratix.net>.
Hi Uli,

there is Chris Schneider´s blog on this topic(s): http://www.liquid-reality.de/display/liquid/2012/07/20/Apache+Karaf+Tutorial+Part+7+-+Camel+JPA+and+JTA+transactions
There is also a post on jdbc and how to install drivers, etc.

Basically for jdbc you need:
- smx/karaf
- camel-jdbc
- an osgi-ified driver (mysqlxxx.jar, whatever) - most recent already contain manifest, etc.
- a datasource.xml (naming is not relevant) where you configure your driver (I think this could also be included in the CamelContext but makes sense to externalize)
- a CamelContext referencing your datasource.xml

I did not try jpa, happy with plain jdbc.
Don´t know about activemq-jdbc persistence: probably ask amq-mailinglist. I suppose there is documentation on that topic.

Cheers, Thomas.

-----Ursprüngliche Nachricht-----
Von: UliSE [mailto:uli.sey@googlemail.com] 
Gesendet: Freitag, 25. Juli 2014 13:21
An: users@servicemix.apache.org
Betreff: Database (jdbc, jpa, XA, ...) setup in Servicemix 5.1.0

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.