Building your first JBoss Fuse project with Maven

Note: There’s an updated tutorial about JBoss Fuse here.

In this tutorial we will create our first Red Hat JBoss Fuse project using Maven. The project will contain a Camel route with OSGi blueprint support that is ready to be deployed in JBoss Fuse.


You need Maven and Red Hat Fuse installed.

Let’s build the project from the camel-archetype-blueprint archetype:


Choose a number or apply filter : camel-archetype-blueprint

Choose archetype:

1: remote -> org.apache.camel.archetypes:camel-archetype-blueprint (Creates a new Camel project with OSGi blueprint support. Ready to be deployed in OSGi.)

Choose a number or apply filter (format: [groupId:]artifactId, case sensitive co

ntains): : 1

Choose org.apache.camel.archetypes:camel-archetype-blueprint version:

. . . .

45: 2.15.0

Choose a number: 45: 45

Define value for property 'groupId': : com.hellofuse
Define value for property 'artifactId': : fuse-blueprint
Define value for property 'version':  1.0-SNAPSHOT: : 1
Define value for property 'package':  com.hellofuse: :

Confirm properties configuration:

groupId: com.hellofuse
artifactId: fuse-blueprint
version: 1

package: com.hellofuse

camel-version: 2.15.0
log4j-version: 1.2.17
maven-bundle-plugin-version: 2.3.7
maven-compiler-plugin-version: 2.5.1
maven-resources-plugin-version: 2.6
slf4j-version: 1.7.10

 Y: : Y

Now the project fuse-blueprint has been created. You can perform the above steps using your favorite IDE as well. In case you have done it using just the shell, just import the Maven project in your IDE. The project contains a blueprint.xml file under src/main/resources/OSGI-INF/blueprint

The Blueprint Service is a way of instantiating and consuming services provided by others by means of an external XML configuration file. The Blueprint service is heavily inspired by the Spring Framework

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

  <bean id="helloBean" class="com.hellofuse.HelloBean">
      <property name="say" value="Hi from Camel"/>

  <camelContext xmlns="">
    <route id="timerToLog">
      <from uri="timer:foo?period=5000"/>
          <method ref="helloBean" method="hello"/>
      <log message="The message contains ${body}"/>
      <to uri="mock:result"/>


The archetype contains a simple Camel Route which moves messages using a Timer component to a Mock endpoint. As the purpose of this tutorial is to create a brand new blueprint we will comment the bean and camelContext defintion.

Defining our service

Our service will move text files contained in the filesystem to the ActiveMQ broker that is embedded into JBoss Fuse. Please note that you need to provide the userName and password created using the esb:create-admin-user in the Fuse console.

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

	<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
		<property name="brokerURL" value="tcp://localhost:61616" />
		<property name="userName" value="admin" />
		<property name="password" value="Password1!" />

	<camelContext xmlns="">
		<route id="file-to-jms-route">
			<from uri="file:/usr/data/in?noop=true" />
			<log message="Receiving order ${file:name}" />
			<to uri="activemq:incomingOrders" />
			<to uri="mock:result"/>


The Mock component included provides a powerful declarative testing mechanism as it allows declarative expectations to be created on any Mock endpoint before a test begins. As the archetype includes a Test class, you can perform a test and the expectations can be asserted in a test case to ensure the system worked as expected.

Here is the Mock class that will be used to test the Service:

public class RouteTest extends CamelBlueprintTestSupport {
    protected String getBlueprintDescriptor() {
        return "/OSGI-INF/blueprint/blueprint.xml";

    public void testRoute() throws Exception {
        // the route is timer based, so every 5th second a message is send
        // we should then expect at least one message

        // assert expectations


That’s all about the code. Now in order to run the test you need to include within your pom.xml include the camel-jms and activemq-camel dependency:


Fine, now start JBoss Fuse:


Execute from the shell:

mvn clean install

This will package your project and execute a route test.

Now install the OSGI bundle on Jboss Fuse. From the Karaf console execute:

JBossFuse:karaf@root> osgi:install -s mvn:com.hellofuse/fuse-blueprint/1

Bundle ID: 259

Now enter the hawtio console at: http://localhost:8181/hawtio/index.html . As you can see, the execution can be debugged from the Camel tab, which contains the statistics about the route that has been invoked:

jboss fuse tutorial example hello world

Within the ActiveMQ tab, you can check for the messages that have been directed to the “incomingOrders” queue:

jboss fuse tutorial example hello world

By clicking on Browse you can display the body of the message as shown by the following picture:

jboss fuse tutorial example hello world