LibraryLink ToToggle FramesPrintFeedback

Generating and Running an EIP Bundle

This section explains how to generate, build, and run a complete Apache Camel example in the OSGi container, where the starting point code is generated with the help of a Maven archetype.

In order to generate a project using an FUSE ESB Maven archetype, you must have the following prerequisites:

The servicemix-osgi-camel-archetype archetype creates a project for building a route that can be deployed into the OSGi container. To generate a Maven project with the coordinates, org.fusesource.example:camel-bundle, enter the following command:

The result of this command is a directory, ProjectDir/camel-bundle, containing the files for the generated bundle project.

To install and run the generated camel-bundle project, perform the following steps:

  1. Build the project—open a command prompt and change directory to ProjectDir/camel-bundle. Use Maven to build the demonstration by entering the following command:

    mvn install

    If this command runs successfully, the ProjectDir/camel-bundle/target directory should contain the bundle file, camel-bundle-1.0-SNAPSHOT.jar and the bundle will also be installed in the local Maven repository.

  2. Install prerequisite features (optional)—by default, the camel-core feature and some related features are pre-installed in the OSGi container. But many of the Apache Camel components are not installed by default. To check which features are available and whether or not they are installed, enter the following console command:

    karaf@root> features:list

    Apache Camel features are identifiable by the camel- prefix. For example, if one of your routes requires the HTTP component, you can make sure that it is installed in the OSGi container by issuing the following console command:

    karaf@root> features:install camel-http
  3. Install and start the camel-bundle bundle—at the FUSE ESB console, enter the following command:

    karaf@root> osgi:install -s file:ProjectDir/camel-bundle/target/camel-bundle-1.0-SNAPSHOT.jar

    Where ProjectDir is the directory containing your Maven projects and the -s flag directs the container to start the bundle right away. For example, if your project directory is C:\Projects on a Windows machine, you would enter the following command:

    karaf@root> osgi:install -s file:C:/Projects/camel-bundle/target/camel-bundle-1.0-SNAPSHOT.jar

    Alternatively, you could install the bundle from the local Maven repository using an Mvn URL (see Mvn URL Handler) as follows:

    karaf@root> osgi:install -s mvn:org.fusesource.example/camel-bundle

    After entering this command, you should soon see output like the following being logged to the console screen:

    >>>> MyTransform set body:  Mon Sep 22 11:43:42 BST 2008
    >>>> MyTransform set body:  Mon Sep 22 11:43:44 BST 2008
    >>>> MyTransform set body:  Mon Sep 22 11:43:46 BST 2008

    On Windows machines, be careful how you format the file URL—for details of the syntax understood by the file URL handler, see File URL Handler.

  4. Stop the camel-bundle bundle—to stop the camel-bundle bundle, you first need to discover the relevant bundle number. To find the bundle number, enter the following console command (this might look a bit confusing, because the text you are typing will intermingle with the output that is being logged to the screen):

    karaf@root> osgi:list

    At the end of the listing, you should see an entry like the following:

    [ 189] [Active     ] [            ] [       ] [   60] A Camel OSGi Service Unit (1.0.0.SNAPSHOT)

    Where, in this example, the bundle number is 189. To stop this bundle, enter the following console command:

    karaf@root> osgi:stop 189