Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fabric deployment 6.1 bundle ordering #12

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.fusesource.example.transactions.database;

/**
* Created by pfox on 06/08/14.
*/
public interface DatabaseBundleMarker {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.fusesource.example.transactions.database;

/**
* Created by pfox on 06/08/14.
*/
public class DatabaseBundleMarkerImpl implements DatabaseBundleMarker {
}
28 changes: 28 additions & 0 deletions database/src/main/resources/OSGI-INF/blueprint/datasource.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
~ Copyright 2011 FuseSource
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">

<reference id="datasource" interface="javax.sql.XADataSource" availability="mandatory" filter="(datasource.name=MySQL)"/>

<!--
Define a Marker service to influcence order of deployment
-->
<bean id="databaseBundleMarker" class="org.fusesource.example.transactions.database.DatabaseBundleMarkerImpl">
</bean>
<service interface="org.fusesource.example.transactions.database.DatabaseBundleMarker" ref="databaseBundleMarker"/>

</blueprint>
25 changes: 10 additions & 15 deletions datasource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,16 @@ relational database.
We are using Blueprint to define the data source bean and publish it into the OSGi Service Registry. Have a look at
`src/main/resources/OSGI-INF/blueprint/datasource.xml` for more details about how this done.

Due to bug http://fusesource.com/issues/browse/ENTESB-633 it is not possible to
have the configured JDBC DataSource getting auto-enlisted into Aries.
Instead a workaround solution is presented in src/main/resources/OSGI-INF/blueprint/datasource.xml


## Checking the OSGi Service Registry
After the bundle is started, we can use the Fuse ESB Enterprise console to look at the registered objects in the registry.

First, find the bundle id for the bundle called "Fuse By Example :: Transactions :: Datasource" by using the `osgi:list` command.
First, find the bundle id for the bundle called " ESB :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource" by using the `osgi:list` command.
You can use `grep` to filter the list of bundles and quickly find the right one.

FuseESB:karaf@root> osgi:list | grep Transactions
[ 268] [Active ] [Created ] [ ] [ 60] Fuse By Example :: Transactions :: Datasource (1.0.0.SNAPSHOT)
[ 269] [Active ] [ ] [ ] [ 60] Fuse By Example :: Transactions :: Database (1.0.0.SNAPSHOT)
[ 270] [Active ] [ ] [Started] [ 60] Fuse By Example :: Transactions :: Routing (1.0.0.SNAPSHOT)
[ 275] [Active ] [Created ] [ ] [ 60] Fuse By Example :: Transactions :: Datasource (1.0.0.SNAPSHOT)

In this example, the bundle id is 268. Using the `osgi:ls` command, we can see that this bundle is publishing 3 services:

Expand All @@ -33,23 +28,23 @@ This is what the `osgi:ls` output looks like

FuseESB:karaf@root> osgi:ls 268

Fuse By Example :: Transactions :: Datasource (268) provides:
Camel :: Demo :: Camel-JMS-JDBC-XA-TX :: DataSource (268) provides:
-------------------------------------------------------------
datasource.name = Derby
datasource.name = MySQL
objectClass = javax.sql.XADataSource
osgi.jndi.service.name = jdbc/transactions
osgi.service.blueprint.compname = derby-cf
osgi.service.blueprint.compname = mysql-cf
service.id = 414
----
aries.xa.aware = true
datasource.name = Derby
datasource.name = MySQL
objectClass = javax.sql.DataSource
osgi.jndi.service.name = jdbc/transactions
osgi.service.blueprint.compname = derby-cf
osgi.service.blueprint.compname = mysql-cf
service.id = 415
service.ranking = 1000
----
objectClass = org.osgi.service.blueprint.container.BlueprintContainer
osgi.blueprint.container.symbolicname = org.fusesource.example.transactions.datasource
osgi.blueprint.container.version = 1.0.0.SNAPSHOT
service.id = 416
osgi.blueprint.container.symbolicname = org.apache.servicemix.demo.camel-jms-jdbc-xa-tx.datasource
osgi.blueprint.container.version = 1.0.0
service.id = 416
52 changes: 35 additions & 17 deletions datasource/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,54 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<artifactId>transactions</artifactId>
<groupId>org.fusesource.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>

<groupId>org.fusesource.example.transactions</groupId>
<artifactId>datasource</artifactId>
<packaging>bundle</packaging>
<name>Fuse By Example :: Transactions :: Datasource</name>
<parent>
<artifactId>transactions</artifactId>
<groupId>org.fusesource.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<groupId>org.fusesource.example.transactions</groupId>
<artifactId>datasource</artifactId>
<packaging>bundle</packaging>
<name>Fuse By Example :: Transactions :: Datasource</name>

<dependencies>


<dependency>
<dependencies>
<dependency>
<groupId>org.apache.geronimo.components</groupId>
<artifactId>geronimo-connector</artifactId>
<version>3.1.1</version>
</dependency>
<version>3.0</version>
</dependency>

<dependency>
<!-- needed for overriding tranql-connector-mysql XAMCF class
<dependency>
<groupId>org.tranql</groupId>
<artifactId>tranql-connector</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.tranql</groupId>
<artifactId>tranql-connector-mysql-common</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.17</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>

</dependency>
-->
<!-- end -->
</dependencies>


<build>
<plugins>
<plugin>
Expand Down

This file was deleted.

153 changes: 47 additions & 106 deletions datasource/src/main/resources/OSGI-INF/blueprint/datasource.xml
Original file line number Diff line number Diff line change
@@ -1,126 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) Red Hat, Inc.

Red Hat licenses this file to you under the Apache License, version
2.0 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing
permissions and limitations under the License.
~ Copyright 2011 FuseSource
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0">

<!-- ********************************************************************* -->
<!-- Workaround for bug http://fusesource.com/issues/browse/ENTESB-633
This configuration will also enlist a JDBC XA DataSource into Aries tx
manager. Once ENTESB-633 is fixed this config should not be needed
anymore. Instead part 2 of the configuration would apply.
-->
<reference id="transactionManager" interface="org.apache.geronimo.transaction.manager.RecoverableTransactionManager" />

<!-- Sets up a Geronimo JCA connection manager which also supports pooling -->
<bean id="connectionManager" class="org.apache.geronimo.connector.outbound.GenericConnectionManager">
<argument index="0">
<bean class="org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions">
<argument value="true" />
<argument value="false" />
</bean>
</argument>
<argument index="1">
<!-- http://geronimo.apache.org/maven/server/modules/geronimo-connector/apidocs/org/apache/geronimo/connector/outbound/connectionmanagerconfig/PartitionedPool.html -->
<bean class="org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool">
<argument value="10" />
<argument value="0" />
<argument value="5000" />
<argument value="15" />
<argument value="true" />
<argument value="false" />
<argument value="false" />
<argument value="true" />
<argument value="false" />
</bean>
</argument>
<argument index="2"><null /></argument>
<argument index="3"><null /></argument>
<argument index="4" ref="transactionManager" />
<argument index="5" ref="jdbcManagedConnectionFactory" />
<argument index="6" value="Derby-DS" />
<argument index="7" ref="classLoader" />
</bean>

<bean id="classLoader" class="org.apache.aries.util.AriesFrameworkUtil" factory-method="getClassLoader">
<argument ref="blueprintBundle" />
</bean>
<service ref="classLoader" auto-export="all-classes" />
<reference id="platformTxManager" interface="org.springframework.transaction.PlatformTransactionManager" availability="optional"/>
<reference id="transactionManager" interface="javax.transaction.TransactionManager" />
<reference id="recoverableTxManager" interface="org.apache.geronimo.transaction.manager.RecoverableTransactionManager" availability="optional" />

<!-- Tranql provides the ManagedConnectionFactory but delegates all the work to the JDBC drivers.
There are factories for every major JDBC provider at
http://search.maven.org/#search|ga|1|tranql-connector
You would need to configure your JDBC provider here.
<!-- NOTE: If you are running JBoss Fuse 6.0, please switch to the demo Camel-JMS-JDBC-XA-TX-JBossFuse6.0.
This version of the demo will not work due to bug http://fusesource.com/issues/browse/ENTESB-633.
The demo Camel-JMS-JDBC-XA-TX-JBossFuse6.0 presents a workaround solution for ENTESB-633
that can be used in JBoss Fuse 6.0.
-->
<bean id="jdbcManagedConnectionFactory" class="org.tranql.connector.derby.ClientXAMCF">
<property name="databaseName" value="transactions"/>
<property name="serverName" value="localhost" />
</bean>

<!-- Creates the JDBC ConnectionFactory -->
<bean id="derby-cf" factory-ref="jdbcManagedConnectionFactory" factory-method="createConnectionFactory">
<argument ref="connectionManager" />
</bean>

<!-- Exports the JDBC ConnectionFactory -->
<service ref="derby-cf" interface="javax.sql.DataSource">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/transactions"/>
<entry key="datasource.name" value="Derby"/>
</service-properties>
</service>

<!-- recoverable ResourceManager for JDBC DataSource, uses a wrapper class -->
<bean id="transactionRecovery" class="org.apache.aries.demo.GenericResourceManager" init-method="doRecovery">
<property name="connectionManagerContainer" ref="connectionManager"/>
<property name="managedConnectionFactory" ref="jdbcManagedConnectionFactory"/>
</bean>


<!-- ********************************************************************* -->
<!-- Part 2:
If bug ENTESB-633 did not exist we could auto-enlist the JDBC driver into
Aries.
-->
<!--
This defines the actual data source bean. It will instantiate a new
ClientXADataSource instance and will use the corresponding settings to set
the database and server name. In our case, we will be running Apache Derby
on the same machine so the server name is `localhost`. A database called
`transactions` has been created up-front as well (see README.md).
-->
<!--
<bean id="transactionsDataSource" class="org.apache.derby.jdbc.ClientXADataSource">
<property name="databaseName" value="transactions"/>
<property name="serverName" value="localhost" />
<bean id="mysql-ds" class="com.mysql.jdbc.jdbc2.optional.MysqlXADataSource">
<property name="databaseName" value="test"/>
<property name="url" value="jdbc:mysql://localhost/test?relaxAutoCommit=true" />
<property name="user" value="root"/>
<property name="password" value=""/>
</bean>


<!-- No pooling classes needed, pooling is provided by Aries wrapper
<bean id="tomcat-jdbc" class="org.apache.tomcat.jdbc.pool.XADataSource">
<property name="dataSource" ref="mysql-ds"/>
<property name="initialSize" value="1"/>
<property name="maxActive" value="5"/>
<property name="jmxEnabled" value="true"/>
</bean>
-->
<!--
We're publishing our data source into the OSGi Service Registry as a
`XADataSource`. This will allow Aries JTA to automatically enlist this
resource as an XA-aware resource. We also assign the
`osgi.jndi.service.name` property to give us an easy-to-use JNDI name to
lookup this data source from our JPA persistence.xml in the `database`
module afterwards.
-->
<!--
<service ref="transactionsDataSource" interface="javax.sql.XADataSource">

<service interface="javax.sql.XADataSource" ref="mysql-ds">
<service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/transactions"/>
<entry key="datasource.name" value="Derby"/>
<entry key="datasource.name" value="MySQL"/>

<!-- additional supported properties
https://github.com/apache/aries/blob/trunk/transaction/transaction-jdbc/src/main/java/org/apache/aries/transaction/jdbc/internal/ManagedDataSourceFactory.java#L94
-->
<entry key="aries.xa.pooling" value="true" />
<entry key="aries.xa.poolMinSize" value="0" />
<entry key="aries.xa.poolMaxSize" value="5" />

</service-properties>
</service>
-->
</blueprint>
Loading