A Look Inside FUSE ESB 4: An OSGi-Based Integration Platform
To run this example you can use the provisioning component in FUSE ESB. Just execute the features install examples-cxf-camel-nmr command and the example will automatically be made active, so the timer will produce a new InOut exchange every 5 seconds.
In the first three examples we mainly focused on the Camel, CXF and NMR functionality available in FUSE ESB. But we can also use the JBI components that were already available in the version 3. Let’s implement an example where we create an OSGi bundle that’s using JBI components and the Camel functionality we already used.
Using JBI components in an OSGi bundle
In the second example we used the JMS functionality provided by Camel. But as you may know, ServiceMix also offers JMS functionality via the JMS binding component. You are free to choose your favorite JMS implementation when using FUSE ESB 4, but the JBI components often provide additional functionality on top of the functionality provided by the corresponding Camel components. In FUSE ESB 3 we had to construct a service assembly and implement service units to use the JBI binding components and service engines. In FUSE ESB 4, we can also use an OSGi bundle with a single XML configuration file, just like we did in the earlier examples, to make use of the JBI components provided by ServiceMix. This eases our effort to develop an integration solution using these JBI components. Be aware that not every JBI component available in FUSE ESB 3 has been made OSGi-ready yet, for example the Apache Ode BPEL service engine can only be used with a service assembly deployment model and the same goes for the JSR181 service engine.
In the next example we’ll configure the File binding component using Camel routing functionality to show the new OSGi bundle deployment model capability for the use of JBI components. A schematic overview of the example is shown in figure 6.

Figure 6 A simple example using the File binding component to show the OSGi bundle deployment model for JBI component configurations.
The main difference with the other examples is that we mainly used Camel functionality there. In this example there is a file poller component which consumes files from the insuranceIn directory and forwards the file contents as a JBI message to the Camel route definition. Then the Camel route definition sends the message on to the file sender, which writes a new file to the insuranceOut directory. To keep things simple we only used the file binding component, but you can imagine that you use all the JBI components which are available in FUSE ESB 4.
Let’s look at the implementation of this simple example. First, the XML configuration of the file poller and sender and the Camel route definition is shown in listing 8.
Listing 8 The XML configuration that defines a file poller, file sender and a Camel route.
<?xml version="1.0"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:file="http://servicemix.apache.org/file/1.0"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:esb="http://fusesource.com/examples/jbicamel"
xmlns:camel-osgi="http://activemq.apache.org/camel/schema/osgi"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://www.springframework.org/schema/osgi-compendium
http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
http://servicemix.apache.org/file/1.0
http://servicemix.apache.org/file/1.0/servicemix-file.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://activemq.apache.org/camel/schema/osgi
http://activemq.apache.org/camel/schema/osgi/camel-osgi.xsd">
<camel-osgi:camelContext xmlns="http://activemq.apache.org/camel/schema/spring">
<package>com.fusesource.camel</package>
</camel-osgi:camelContext>
<file:poller service="esb:insuranceFileService"
endpoint="pollerEndpoint"
targetService="esb:insuranceCamelRouter"
file="insuranceIn"
delay="5000"
period="2000"/>
<file:sender service="esb:insuranceFileService"
endpoint="senderEndpoint"
directory="insuranceOut"/>
<osgi:reference id="jbi" interface="org.apache.camel.Component"/>
<bean class="org.apache.servicemix.common.osgi.EndpointExporter" />
</beans>
The Camel route definition is already shown in a previous example. What’s new here is the file poller and file sender definition. For JBI components you always have to configure a service and endpoint name because this uniquely identifies the JBI component in the container. For the file poller a targetService attribute is configured which defines the target component where the consumed file content is sent to. So this makes sure that the file content is sent to the Camel router.
In addition to the file poller and sender, we need to define an EndpointExporter bean that registers the poller and sender service and endpoint name in the OSGi registry. We also need to define an OSGi reference with an identifier of jbi, which enables the Camel route definition to talk with the JBI components. In the RouteBuilder class shown in listing 9, this jbi identifier is used.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)











Comments
davsclaus replied on Wed, 2009/03/11 - 12:57am
Maybe the description for the Camel SEDA and VM components, could be changed to:
- asynchronous call to another endpoint in the same Camel Context
- asynchronous call to another endpoint in the same JVM The List component is renamed to Browse in Camel 2.0 as a better name what it does, eg being able to browse Messages that have passed it.
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
davsclaus replied on Wed, 2009/03/11 - 1:03am
davsclaus replied on Wed, 2009/03/11 - 1:06am
AMQ web console:
http://activemq.apache.org/web-console.html
trademak replied on Wed, 2009/03/11 - 2:24am
ty_780823 replied on Sat, 2009/03/14 - 9:21am
The same greate and wonderful article as "Open-Source ESB In Action"!
I wish that you can contribute more excellent article about enterprise integration.
Especially about the key technoledge points of open source integration(such as spring with mule,spring with servicemix,...).
--- Mike Tang
Sun Glassfish FishCat Contributor
Open Source Integration Fans
Blog: http://mikertang.blogspot.com/
trademak replied on Sat, 2009/03/14 - 11:51am
in response to: ty_780823
Robert Williams replied on Wed, 2009/03/18 - 7:42am
Could not download the article source code at the URL listed.
Could you please make the article source code available
BTW Nice article!
teseling replied on Wed, 2009/03/18 - 8:12am
in response to: rjwil35
trademak replied on Wed, 2009/03/18 - 2:52pm
in response to: teseling
teseling replied on Wed, 2009/03/18 - 5:39pm
in response to: trademak
emad964 replied on Mon, 2009/06/29 - 4:35pm
jiji530 replied on Tue, 2009/06/30 - 12:21am
Sandra Hong replied on Wed, 2009/07/29 - 12:19am
Xiamenlqy replied on Sat, 2009/09/05 - 4:17am