Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Este contenido no está disponible en el idioma seleccionado.
Chapter 13. FAB Tutorial
Abstract
This tutorial describes a complete example of how to generate, build, run, and deploy a Apache Camel application as a FAB.
13.1. Generating and Running an EIP FAB Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Overview Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
This section explains how to generate, build, and run a complete Apache Camel example as a FAB, where the starting point code is generated with the help of a Maven archetype.
Prerequisites Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
In order to generate a project using an Red Hat JBoss Fuse Maven archetype, you must have the following prerequisites:
- Maven installation—Maven is a free, open source build tool from Apache. You can download the latest version from http://maven.apache.org/download.html (minimum is 2.0.9).
- Internet connection—whilst performing a build, Maven dynamically searches external repositories and downloads the required artifacts on the fly. In order for this to work, your build machine must be connected to the Internet.
- fusesource Maven repository is configured—in order to locate the archetypes, Maven's
settings.xmlfile must be configured with the location of thefusesourceMaven repository. For details of how to set this up, see the section called “Adding the Red Hat JBoss Fuse repository”.
Generating an EIP FAB Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
The
camel-archetype-blueprint archetype creates a sample Maven project that can be deployed as a FAB. To generate a Maven project with the coordinates, org.fusesource.example:camel-fab, enter the following command:
The result of this command is a directory,
ProjectDir/camel-fab, containing the files for the generated FAB project.
Modify the POM file Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
By default, the generated project's POM is configured as an OSGi bundle, not a FAB. To convert the
camel-fab/pom.xml file to a FAB POM, modify it as follows:
- Open the
camel-fab/pom.xmlfile with your favorite text editor and change the packaging type frombundletojar, as follows:<groupId>org.fusesource.example</groupId> <artifactId>camel-fab</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version>
<groupId>org.fusesource.example</groupId> <artifactId>camel-fab</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the
providedscope to all of the dependencies (except for the dependencies that are already marked withtestscope). Scroll down to thedependencieselement and add ascopeelement to each of the dependencies as shown:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Remove the Maven bundle plug-in configuration. Scroll down to the
pluginssection and remove the completepluginelement corresponding to themaven-bundle-pluginplugin. - Save and close the
camel-fab/pom.xmlfile.
Running the EIP FAB Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
To install and run the generated
camel-fab project, perform the following steps:
- Build the project—open a command prompt and change directory to
ProjectDir/camel-fab. Use Maven to build the demonstration by entering the following command:mvn install
mvn installCopy to Clipboard Copied! Toggle word wrap Toggle overflow If this command runs successfully, theProjectDir/camel-fab/targetdirectory should contain the JAR file,camel-fab-1.0-SNAPSHOT.jarand the JAR will also be installed in the local Maven repository. - Install the fabric-bundle feature—the
fabric-bundlefeature is a prerequisite for using FABs. If it is not already installed, enter the following command:JBossFuse:karaf@root> features:install fabric-bundle
JBossFuse:karaf@root> features:install fabric-bundleCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Install and start the camel-fab JAR—at the Red Hat JBoss Fuse console, enter the following command:
JBossFuse:karaf@root> install fab:mvn:org.fusesource.example/camel-fab
JBossFuse:karaf@root> install fab:mvn:org.fusesource.example/camel-fabCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIt can take a minute or so for theinstallcommand to finish, because the FAB runtime needs some time to evaluate the tree of dependencies associated with thecamel-fabartifact.If the FAB is successfully installed, its bundle ID is logged to the console window. Using this bundle ID, bundleID, start the FAB by entering the following console command:JBossFuse:karaf@root> fab:start bundleID
JBossFuse:karaf@root> fab:start bundleIDCopy to Clipboard Copied! Toggle word wrap Toggle overflow - View the log—After entering the
fab:startcommand, the Camel route starts to log messages to the container's log. To view the log, enter the following command:JBossFuse:karaf@root> log:tail -n 10
JBossFuse:karaf@root> log:tail -n 10Copy to Clipboard Copied! Toggle word wrap Toggle overflow You should see messages like the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow To exit the log, type Ctrl-C. - Stop the camel-fab bundle—using the FAB's bundle ID, bundleID, stop the
camel-fabbundle, as follows:JBossFuse:karaf@root> fab:stop bundleID
JBossFuse:karaf@root> fab:stop bundleIDCopy to Clipboard Copied! Toggle word wrap Toggle overflow