LibraryLink ToToggle FramesPrintFeedback

Migrating Apache Camel Applications to OSGi

In Fuse ESB 4.3, the recommended approach to deploying an applications is as an OSGi bundle. If you have an existing application that is packaged as a JBI project, you can migrate it to an OSGi bundle as follows:

The easiest way to obtain a POM file with the correct settings for a Apache Camel application bundle is to generate a new Maven project using the servicemix-osgi-camel-archetype archetype.

For example, to generate a Maven project with the coordinates, GroupId:ArtifactId:Version, enter the following Maven command (all on one line):

mvn archetype:create
-DarchetypeGroupId=org.apache.servicemix.tooling
-DarchetypeArtifactId=servicemix-osgi-camel-archetype
-DarchetypeVersion=2010.02.0-fuse-00-00
-DgroupId=GroupId
-DartifactId=ArtifactId
-Dversion=Version

For more details about how to use archetypes in Fuse ESB, see Generating a Maven Project in Deploying into the OSGi Container.

JBI projects for a Apache Camel contain at least two sub-projects:

OSGi Apache Camel applications, on the other hand, are built as a single project. You need to copy the relevant source files from the old SU project to the newly generated Maven project. The relevant directories in the new Maven project are, as follows:

MavenProjectDir/src/main/java
MavenProjectDir/src/main/resources/META-INF/spring

The Jave source code from the SU should be moved to the src/main/java directory in the new Maven project and any Spring configuration files (including camel-context.xml) should be moved to the src/main/resources/META-INF/spring directory.

The default bundle plug-in settings are probably compatible with most applications. It is advisable, however, to familiarize yourself with the settings and to decide whether or not they need to be customized. For details, see Configuring the Bundle Plug-In in Deploying into the OSGi Container.

The XML namespace for the Spring DSL schema has changed between Apache Camel 1.x and Apache Camel 2.x, as follows:

Old XML schema namespace:

http://activemq.apache.org/camel/schema/spring

New XML schema namespace:

http://camel.apache.org/schema/spring

Moreover, when specifying the xsi:schemaLocation attribute, you need to specify the location of the new XML schema. For example, the namespace settings (which are typically defined in a Spring bean element) should be changed as follows:

Old namespace definitions in bean element:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://activemq.apache.org/camel/schema/spring"
       xsi:schemaLocation="
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

New namespace definitions in bean element:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xsi:schemaLocation="
         http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">