No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

SMX Demo


mvn install

This will install it to your local maven repository.

Prepare the datasource

The demo uses the viiper-ds datasource which must be made available to the servicemix environment. Since this is dependent on the environment where we would deploy our packages, this would be something prepared by the sysadmins.

In this case we need to use the oracle driver.

karaf@root> osgi:install wrap:mvn:ojdbc/ojdbc5/

Please check the actual version number as this is updated from time to time.

To define a datasource to be used, in this case viiper_ds we can create a small spring configuration file which we deploy to the hot deploy folder <SMX_HOME>/deploy.

<beans xmlns=""
  <bean id="viiper-ds" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
    <property name="connectionCachingEnabled" value="true" />
    <property name="URL">
    <property name="user">
    <property name="password">
    <property name="connectionCacheProperties">

  <osgi:service ref="viiper-ds" interface="javax.sql.DataSource"/>


This creates a small connection-pool using the Oracle provided implementation in the driver package. For other drivers which do not come with a connection pool I recommend to wrap them in the C3P0 connection-pool, but this demo uses oracle, so its not needed.

Lets check if it worked :

karaf@root> list
[ 222] [Active     ] [            ] [       ] [   60] wrap_mvn_ojdbc_ojdbc5_11. (0)
[ 239] [Active     ] [            ] [       ] [   60] oracle_pool.xml (0.0.0)

I called the spring xml file oracle_pool.xml amd we see it is Active. Similar for the wrapped jdbc driver in the oracle provided ojdbc jar.

Note: we can refer to these bens in our camel spring configuration :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

        <camel:routeBuilder ref="route"/>

    <bean id="route" class="com.melexis.Route"/>

    <osgi:reference id="viiper-ds" interface="javax.sql.DataSource" bean-name="viiper-ds"/>

    <bean id="transactionId" class="com.melexis.Route$TransactionId"/>

The <osgi:reference ...> element will import the datasource. To select the right datasource use the bean-name attribute to specify the id in the datasource definition (which corresponds to the content of the ref attribute in the osgi:service element). The id of the osgi:reference element is the name the bean will be known in our application.

Prepare the camel components on the container

Since we want to reuse as much as possible existing lego-blocks there is a big box of blocks included in the ServiceMix container. However before we can use them, we must take them out of the storage box.

In this case we need the additional blocks 'camel-stream' and 'camel-jdbc'.

karaf@root> features:install camel-stream
karaf@root> features:install camel-jdbc

Note that this only needs to be done once, and is something which is normally done by the sysadmins, or by a dependency management package.

Deploy our demo

Finally we can deploy the fruits of our labour.

In servicemix execute:

karaf@root> osgi:install mvn:com.melexis/smxdemo/1.0.0-SNAPSHOT/jar
karaf@root> osgi:list 242
[ 242] [Installed  ] [            ] [       ] [   60] smxdemo (1.0.0.SNAPSHOT)

Which will install the bundle on your servicemix platform, as we can see by listing the bundles.

and try to start it.

karaf@root> osgi:start 242
karaf@root> osgi:list
[ 242] [Active     ] [            ] [       ] [   60] smxdemo (1.0.0.SNAPSHOT)

Yay!!! It runs.....

Well, it might not look to work for a while if you did not update the start transaction id to some recent number. It will return 1000's of results and take forever. (exercise to the reader : make the initialisation start from the current transaction id when starting the route)