osgi-karaf-multiple versions of service and camel route

One of the benefits of OSGi is Versioning as explained here. As per the documentation, OSGi can host different versions of "same jar" and let the other applications access them accordingly.

I have been given a task to leverage the same properties of OSGi (I am using Apache-Karaf container) using Camel routes.

I have to deploy multiple versions of a service and have Camel, route to the proper one based on the request. I extensively searched google but I haven't found a suitable example :(

Please throw me any pointers or guide me to an example.


By service, I mean osgi bundle service which is defined like this

  <osgi:service ref="transformService">

I have followed the steps provided in this tutorial to create a service called transformService and TransformServiceImpl is the implementation class for this service.

Now let's say I will modify TransformServiceImpl and release it as new version (by updating my version in pom.xml). Also, I will install both the versions, that is, demo.service-0.1.jar and demo.service-0.2.jar in Karaf (which is OK with Karaf). In this case how can I route to a particular version of service ?

Can I create 2 osgi:reference which points to same service but different versions? Something like this?

 <osgi:reference id="myTransformV0.1" version="0.1" interface="demo.service.TransformService"/>
 <osgi:reference id="myTransformV0.2" version="0.2" interface="demo.service.TransformService"/> 

And use them in routes?

 <camelContext xmlns="http://camel.apache.org/schema/spring">
      <from uri="timer://myTimer?fixedRate=true&amp;period=10000"/>
                <when ...> <bean ref="myTransformV0.1" method="transform"/>
                <otherwise> <bean ref="myTransformV0.2" method="transform"/>
      <to uri="log:ExampleRouter"/>


OSGi versioning is different from the Service versioning. I think the key question is how can you access these camel route with different version.

If your camel route provides RESTful service, it could be easy to provide different version by using different url, such as "/service/v1", "/service/v2". But it is not same with the OSGi versioning, you still need to do some work to fill the gap.

Need Your Help

How to install postgres-9.1 on Ubuntu 10.04 LTS?

ubuntu-10.04 postgresql-9.1 aptitude

Many months ago, I installed postgres 8.4 using the following command:

ASP.Net application security design (remember previous passwords)

asp.net sql-server-2008 security passwords

I am working on an asp.net application where one of the security requirements is that the application must enfore "password history" - (remember previous 8 passwords).