Riding the Camel with WildFly application server

User Rating: 4 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Inactive
 

This tutorial describes how you can integrate Apache Camel in your WildFly Application Server configuration. At the end of this tuorial you will be able to turn your WildFly application server into a mini service bus!

First of all, you need to grab the WildFly-camel bundle which is available at https://github.com/wildfly-extras/wildfly-camel

Simply unzip the tar.gz file into your application server home directory

tar xvfz wildfly-camel-patch-2.2.0.tar.gz 

The above archive will extract modules and two configuration files named standalone-camel.xml and domain-camel.xml

Within the configuration file, you will find the the WildFly's Camel subsystem which allows you to add Camel Routes as part of the WildFly configuration. Routes can also be deployed as part of JavaEE applications and JavaEE components can access the Camel Core API and various Camel Component APIs.

Let's see a simple example of a route which moves files from one folder to another:

<subsystem xmlns="urn:jboss:domain:camel:1.0">
   <camelContext id="system-context-1">
	 <![CDATA[
	 <route>
		<from uri="file:/home/wildfly/in?noop=true"/>
		<to uri="file:/home/wildfly/out"/>
	 </route>
	 ]]>
   </camelContext>
</subsystem>

In order to test the above route, simply place a file into the "from" route and expect to find them copied into the "to" part of the route. If the files path are correct, the file transfer will work as you start the application server with a camel configuration.

Ex:

./standalone.sh -c standalone-camel.xml

The Camel bundle also includes hawtio console which will let you dig into the Camel subsystem.

A login/password will be requested to access:

Where are user/names and password stored ? Obviously in a security domain:

<security-domain name="hawtio-domain" cache-type="default">
	<authentication>
		<login-module code="RealmDirect" flag="required">
			<module-option name="realm" value="ManagementRealm"/>
		</login-module>
	</authentication>
</security-domain>

The hawtio-domain security domain relies on the RealmDirect and ManagementRealm, therefore you can use WildFly administration user and password to access the hawtio console as well

As you can see, by selecting the Camel tab, you can get right into the Attributes of your route which was executed once:

camel wildfly tutorial

The route diagram shows the nodes which have been executed (you can even debug the execution of the route!):

camel wildfly turorial

This was just a quick introduction to the Camel integration with WildFly. In the part two of this tutorial we will show how to use Camel routes in Java EE applications using the Camel subsystem. A big thanks to Thomas Diesler for setting up this awesome project on GitHub!

Related articles available on mastertheboss.com

Wildfly 8 introduction

JBoss AS has a new name: as you probably know future versions of

Configuring Eclipse to use WildFly

This tutorial shows how to install JBoss Tools 4.3.1 plugin 

Maven configuration for Java EE 7 projects on WildFly

In this tutorial we will learn how to configure Maven Project Obj

Running WildFly with JDK 8

The JDK 1.8 early access is available for download at Oracle's si

Patching WildFly application server

The final version of WildFly 8.1.0 has been released and it conta

Configuring WildFly Batch Job Repository

WildFly ships with a subsystem named batch which is the administr

Follow us on Twitter