In this tutorial you will:
create a routing project
add endpoints to a route
connect two endpoints
configure the endpoints
To create a Fuse project:
Open the JBoss perspective.
This is the default perspective when you start up JBoss Developer Studio for the first time.
On the Toolbar, select New Fuse project wizard, as shown in Figure 1, “New Fuse project location page”.
> > to open theClick New Fuse Project details page, as shown in Figure 2, “New Fuse project details page”.
to open theSelect camel-archetype-spring
.
Enter tutorial
in the
Group Id: field.
Enter simple-route
in the
Artifact Id: field.
The Version: field defaults to
1.0.0-SNAPSHOT
. To change it, enter
a different version identifier.
The Package: field defaults to
tutorial.simple.route
, the name of
the package that contains
camel-archetype-spring
. To include
the route in a different package, enter the name of that
package.
Click
.This procedure creates a Fuse project,
simple-route
, in Project
Explorer that contains everything needed to
create and run routes. As shown in Figure 3, the files generated
for simple-route
include:
To create the new route:
In Project Explorer, locate
simple-route/src/main/resources/META-INF/spring/camel-context.xml
.
Right-click it to open the context menu, then select Delete.
You're going to replace the old
camel-context.xml
file with your
own to create a new route.
In the Delete dialog, click OK to confirm the operation.
In Project Explorer, select
simple-route/src/main/resources/META-INF/spring
.
Right-click it to open the context menu.
Select Camel XML File wizard, as shown in Figure 4.
> to open theCheck that
/simple-route/src/main/resources/META-INF/spring
appears in the Container: field.
Otherwise enter it manually, or select it using the button.
![]() | Note |
---|---|
The |
Check that camelContext.xml
appears
in the File Name: field. Otherwise
enter it manually.
Check that Framework field, or select it from the field's drop-down list.
appears in theClick
.![]() | Note |
---|---|
By default, Outline view is located in the upper, right corner of the JBoss perspective. To provide more room for Design view to display the graphical representation of your route, drag Outline view to the lower, left corner of the workspace, below Project Explorer. |
Click the Source tab at the bottom,
left of the canvas to open the new
camelContext.xml
file in the route
editor's Source view, as shown in Figure 5, “New camelContext file in the route editor's source
view”.
Click the Design tab at the bottom, left of the canvas to return to the route editor's Design view.
Drag an Endpoint element () from the Palette
to the canvas.
Drag a second Endpoint element from the Palette to the canvas.
Select the first endpoint you dragged onto the canvas.
The Properties editor, located below the canvas, displays the endpoint's property fields for editing, as shown in Figure 6, “Endpoint property editor”.
Enter file:src/data?noop=true
in
the Uri field. Leave the other fields
blank.
Select the second endpoint you dragged onto the canvas.
Enter file:target/messages/others
in the Uri field. Leave the other
fields blank.
On the canvas, select the first endpoint
(file:src/data?noop=true
), and
drag it's connector arrow () to the second endpoint
(
file:target/messages/others
),
then release it.
A segmented line connects the two endpoints, as shown in Figure 7.
![]() | Note |
---|---|
You can drag the line's bendpoint (orange dot) to change the angle of the line's segments. Doing so creates two new bendpoints, one on either side of the original. This behavior enables you to easily adjust your diagram to accommodate increasingly complex routes. |
To quickly align the connected endpoints, right-click the canvas to open the context menu, and then select
.Select
> to save the route.Click the Source tab at bottom, left of the canvas.
Source view displays the XML for the
route. The camelContext
element
will look like Example 1.
Example 1. XML for simple route
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:camel="http://camel.apache.org/schema/spring" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> <camelContext trace="false" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="file:src/data?noop=true"/> <to uri="file:target/messages/others"/> </route> </camelContext> </beans>
After you have created and designed your route, you can run it by deploying it into your Apache Camel runtime, as described in To Run a Route.
To learn more about:
using the editor, see Red Hat JBoss Fuse Tooling: JBoss Fuse Tooling User Guide at https://access.redhat.com/site/documentation/JBoss_Fuse/
Apache Camel endpoints, see Red Hat JBoss Fuse: Component Reference that comes with Red Hat JBoss Fuse.