Author: Fuse Team
Level: Beginner
Technologies: Camel
Summary: This quickstart shows a simple Apache Camel application that logs a message to the server log every 5th second.
Target Product: Fuse
Source: https://github.com/jboss-fuse/quickstarts
This quick start shows how to create a simple Apache Camel application that logs a message to the server log every 5th second.
This example is implemented using solely the XML DSL (there is no Java code). The source code is provided in the following XML file src/main/resources/OSGI-INF/blueprint/camel-log.xml
.
This example uses a timer to trigger every 5th second, and then writes a message to the server log, as shown in the diagram below:
Before building and running this quick start you need:
- Maven 3.1.1 or higher
- JDK 1.7 or 1.8
- JBoss Fuse 6
- Change your working directory to
camel-log
directory.
-
Run
mvn clean install
to build the quickstart. -
Start JBoss Fuse 6 by running bin/fuse (on Linux) or bin\fuse.bat (on Windows).
-
In the JBoss Fuse console, enter the following command:
osgi:install -s mvn:org.jboss.quickstarts.fuse/beginner-camel-log/6.3.0.redhat-187
-
Fuse should give you an id when the bundle is deployed
-
You can check that everything is ok by issuing the command:
osgi:list
your bundle should be present at the end of the list
To use the application be sure to have deployed the quickstart in Fuse as described above.
- At the fuse prompt, enter the following command: log:tail
- Every 5 seconds you will see a message containing ">>> Hello from Fabric based Camel route!"
- Hit ctrl-c to return to the fuse prompt.
To stop and undeploy the bundle in Fuse:
-
Enter
osgi:list
command to retrieve your bundle id -
To stop and uninstall the bundle enter
osgi:uninstall <id>
-
Start JBoss Fuse 6 by running bin/fuse (on Linux) or bin\fuse.bat (on Windows).
-
In the JBoss Fuse console, enter the following command:
fabric:create --wait-for-provisioning
The example comes as source code and pre-built binaries with the fabric8 distribution.
To try the example you do not need to build from source first. Although building from source allows you to modify the source code, and re-deploy the changes to fabric. See more details on the fabric8 website about the developer workflow.
To build from the source code:
- Change your working directory to
quickstarts/beginner/camel-log
directory. - Run
mvn clean install
to build the quickstart. - Run
mvn fabric8:deploy
to upload the quickstart to the fabric container.
If you run the fabric:deploy
command for the first then, it will ask you for the username and password to login the fabric container.
And then store this information in the local Maven settings file. You can find more details about this on the fabric8 website about the Maven Plugin.
The following information is divided into two sections, whether you are using the command line shell in fabric, or using the web console
You can deploy and run this example at the console command line, as follows:
-
It is assumed that you have already created a fabric and are logged into a container called
root
. -
Create a new child container and deploy the
quickstarts-beginner-camel.log
profile in a single step, by entering the following command at the console:fabric:container-create-child --profile quickstarts-beginner-camel.log root mychild
-
Wait for the new child container,
mychild
, to start up. Use thefabric:container-list
command to check the status of themychild
container and wait until the[provision status]
is shown assuccess
.
-
Log into the
mychild
container using thefabric:container-connect
command, as follows:fabric:container-connect mychild
-
View the container log using the
log:tail
command as follows:log:tail
To exit the tail logger, press Ctrl-D. And to logout from the mychild
container, then use the exit
command, which returns back to the root
container.
To stop and undeploy the example in fabric8:
-
Disconnect from the child container by typing Ctrl-D at the console prompt.
-
Stop and delete the child container by entering the following command at the console:
fabric:container-stop mychild fabric:container-delete mychild
You can deploy and run this example from the web console, as follows
- It is assumed that you have already created a fabric and are logged into a container called
root
. - Login the web console
- Click the Wiki button in the navigation bar
- Select
quickstarts
-->beginner
-->camel.log
- Click the
New
button in the top right corner - In the Create New Container page, enter
mychild
in the Container Name field, and click the Create and start container button
This example comes with sample data which you can use to try this example
- Login the web console
- Click the Containers button in the navigation bar
- Select the
mychild
container in the containers list, and click the open button right next to the container name. - A new window opens and connects to the container. Click the Logs button in the navigation bar if the logs are not already displayed
- You can also click the Camel button in the top navigation bar, to see information about the Camel application.
To stop and undeploy the example in fabric8:
- In the web console, click the Runtime button in the navigation bar.
- Select the
mychild
container in the Containers list, and click the Stop button in the top right corner