Enterprise Integration Zone is brought to you in partnership with:

Tijs has posted 3 posts at DZone. View Full User Profile

A Look Inside FUSE ESB 4: An OSGi-Based Integration Platform

03.10.2009
| 96448 views |
  • submit to reddit

Recently, version 4 of the FUSE ESB was released, which is the enterprise support version of Apache ServiceMix 4, rebranded by Progress Software (previously IONA), but still fully open source and Apache licensed. This new major version of the FUSE ESB is founded on OSGi and introduces a number of new deployment models, in addition to JBI 1.0, which makes your life as an integration developer far easier.

In this article I’ll introduce you to the new version of FUSE ESB by explaining the new functionality of the ServiceMix Kernel and NMR projects with a number of hands-on examples. In order to try the examples covered in this article, you can download a copy of FUSE ESB from http://fusesource.com

Didn’t FUSE ESB support JBI?

Yes, in version 3 of FUSE ESB (based on Apache ServiceMix 3.x), the architecture is based on JBI 1.0. This means that the integration functionality provided by FUSE ESB can be implemented with service engines (SEs) and binding components (BCs), which are connected via a normalized message router. And with services assemblies (SAs) and service units (SUs) you can deploy integration functionality via Ant tasks or Maven plugins to the ServiceMix container. For more detailed information about version Apache ServiceMix 3 you can read another article I wrote for DZone, Pattern Based Development with ServiceMix.

But did this all change in version 4 of FUSE ESB? Well, yes and no. Version 4 is based on OSGi bundles and the classloading model of JBI 1.0 has been superseded by OSGi. You can now deploy your integration artifacts as OSGi bundles on the ServiceMix container; however, JBI 1.0 is still supported with version 4 and the JBI components like the JMS BC, File BC, Validation SE and the Bean SE are still there. So you can still deploy your good old service assemblies to the ServiceMix 4 container without any need to change the implementation from ServiceMix 3.

FUSE ESB 4 architecture

But let’s not stick too much in comparing version 3 and 4, and have a look at the new architecture of FUSE ESB 4. Fuse ESB 4 consists of two main projects: the kernel and the NMR, as shown in figure 1.

Figure 1 The architecture of FUSE ESB 4, which is based on OSGi.

The kernel component is the foundation of FUSE ESB 4. The kernel provides an OSGi-based platform using Apache Felix (although other OSGi containers can also be used) with a number of components on top. First there is the console, which is the central tool to interact with the kernel. When you start FUSE ESB, the console is started automatically, so you can manage the ESB environment. Starting the FUSE ESB is very easy, just open a command prompt and go to the installation directory of the FUSE ESB, e.g. c:\fuse-esb-4.0.0.4 Then enter the following command to start the ESB.

Windows: bin\servicemix.bat

Linux/Unix: bin/servicemix.sh

When the FUSE ESB has started, a console similar to figure 2 is shown.

Figure 2 A screenshot of the Fuse ESB console, which is started with the Fuse ESB.

The console is very intuitive and easy to use. There’s a handy ‘help’ option that you can use to get familiar with the commands. A command that you’ll be using quite often when using FUSE ESB is the ‘osgi list’ command. This shows an overview of all installed OSGi bundles on the container. To manage the bundles there are several commands that you can use like ‘osgi install’, ‘osgi uninstall’, ‘osgi start’ and ‘osgi stop’. An overview of all the OSGi related commands can be retrieved with the ‘osgi help’ command.

Instead of discussing all the components shown in figure 1 one-by-one, let’s first look at a small example to get familiar with the basic components of the FUSE ESB.

A short Camel ride

One of the main changes between version 3 and 4 of FUSE ESB is the integration with Apache Camel (http://activemq.apache.org/camel) to implement routing functionality. In version 3 there was already support for Camel with the Camel service engine, but in version 4 Camel is integrated in the core of the ServiceMix container. So let’s explore the use of Camel routing inside the FUSE ESB a bit.

With Camel, we have two options to implement the integration logic, a Java class using the Java domain specific language (DSL) or a Spring XML configuration file using the Camel XSD. For this first example we’ll use the Spring XML configuration option, because we can deploy this directly to the FUSE ESB without any packaging. Let’s look at a very simple example, where a file is moved from one directory, camel-test-in, to another directory, camel-test-out, in listing 1.

Listing 1 Spring configuration file, camel-file-test.xml, using Camel to move a file to another directory.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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-2.5.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.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">
<route>
<from uri="file:camel-test-in"/>
<to uri="file:camel-test-out"/>
</route>
</camel-osgi:camelContext>
</beans>

As you can see in listing 1, we can define a Camel route configuration directly in a Spring XML configuration file. In this Camel configuration the Camel OSGi module is used. In the route element definition a source directory is configured with the from element and a target directory with the to element.

Before we can deploy this Camel example, we first have to install the Camel component on the FUSE ESB container. This is a good time to talk about the provisioning component implemented in the FUSE ESB kernel, also shown in figure 1. To provide a flexible way of installing new OSGi bundles to the FUSE ESB container, the kernel provides several sources, including Maven artifacts, URLs and local file paths. To interact with the provisioning component the features command can be used in the console of the FUSE ESB container. To get an overview of features that can be installed on the FUSE ESB container you can use the ‘features list’ command. A feature consists of one or more OSGi bundles and provides specific functionality that can be used to develop integration functionality. By default, the result of the ‘features list’ command is an substantial number of components, including Camel, ActiveMQ, the JBI components that we could already use in FUSE ESB 3, and the NMR project.

To get our simple Camel example running, we need to install the Camel functionality. The installation of a specific feature is very simple to do with the console. Just run the command ‘feature install camel’, where camel can of course be replaced by other features you may wish to install. The feature name should be exactly the same as the name you see as a result of the ‘feature list’ command. When the Camel feature is installed, the Camel file example can easily be deployed on the FUSE ESB by copying the Camel configuration file, camel-file-test.xml, to the deploy directory in the FUSE ESB installation directory.

If the FUSE ESB has been started you can now see that the Camel file example has been installed by executing the ‘osgi list’ command. The last OSGi bundle that is showed in the list is now the camel-file-test.xml bundle with a status of active. This means that the FUSE ESB has already started the Camel file example OSGi bundle and is polling the camel-test-in directory for files. If you copy a file to the camel-test-in directory it is consumed by the FUSE ESB container and a new file with the same content is created in the camel-test-out directory. So, we can use the components provided by Camel out-of-the-box in the FUSE ESB container, and we don’t have to create a JAR file or another deployment package, we can use a Spring XML configuration and your mediation flow is deployed and running.

Published at DZone with permission of its author, Tijs Rademakers.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Claus Ibsen replied on Wed, 2009/03/11 - 12:57am

Very nice article.

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/

Claus Ibsen replied on Wed, 2009/03/11 - 1:03am

I am wondering if in listening 3 the reference for the connectionFactory should be pooledConnectionFactory instead? Well at least you would assume this when reading the AMQ configuration below.

Claus Ibsen replied on Wed, 2009/03/11 - 1:06am

ActiveMQ comes with a web console, I was wondering if that is can be used for sending new messages to a JMS queue instead of having to install Hermes and find out how to get it connected with AMQ.

AMQ web console:
http://activemq.apache.org/web-console.html

Tijs Rademakers replied on Wed, 2009/03/11 - 2:24am

Hi Claus, Thanks, I changed the VM and SEDA description to your descriptions. About listing 3, the pooledConnectionFactory ref attribute value is pointing to the Spring bean definition in the activemq-broker.xml file. So the name I gave the JMS ConnectionFactory in listing 3 is just a name that's used within this FUSE JMS configuration. And yes, the web console can of course also be used to send a message to a JMS queue. Hermes is a nice alternative with some more features. Best regards, Tijs

Tang Yong replied on Sat, 2009/03/14 - 9:21am

Hi trademak,

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/

Tijs Rademakers replied on Sat, 2009/03/14 - 11:51am in response to: Tang Yong

Hi Mike, Thanks! I have plans to write some more articles about open source integration (as time permits). Best regards, Tijs

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! 

Erwin Teseling replied on Wed, 2009/03/18 - 8:12am in response to: Robert Williams

I would also like to download the source, could you provide an updated link?

Tijs Rademakers replied on Wed, 2009/03/18 - 2:52pm in response to: Erwin Teseling

Hi, I've added the source code to my own web page at esbinaction.com. I changed the download link in the article. Let me know if you still run into problems. Best regards, Tijs

Erwin Teseling replied on Wed, 2009/03/18 - 5:39pm in response to: Tijs Rademakers

Thanks a lot. I still had some problems with the correct pom.xml settings in order to gets things working, but with the source I managed to get it working!

Ali Yang replied on Wed, 2010/07/14 - 10:59am

Hi Tijs, I have talked with a guy from FUSE. He said OSGi Service function just like a registry in OSGi container. It is very simple. So what about your opinion? What is the benefit to use OSGi Service to expose functions in one Bundle to other Bundles in OSGi container? Thanks

Mohit Dklkjhsds replied on Mon, 2010/08/16 - 10:20am

Hi Tijs, I am fairly new to java,i have just worked on a very modest core java project.I have little idea of web services but i am a complete stranger to the terminologies like FUSE ESB,JBI,OSGI,CAMEL,SERVICEMIX. Can you please suggest what i must first get acquainted with before jumping into this ,if it requires any prior knowledge(which, i am almost certain it does).Or if possible can you please dumb it down a little for people like me who have very little idea what FUSE ESB is all about and also a little about it's other components. Thanks & Regards Mohit

Larry Xu replied on Mon, 2010/11/15 - 3:27am

where is the source code ?

Dead Devil replied on Tue, 2011/03/15 - 4:17pm

Greetings!! Many thanks for the examples but i have some issues with this. When i deploy camel-jms-example-1.0.jar, by copying it to the deploy directory, i get this error Exception in thread "SpringOsgiExtenderThread-6" java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171) at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextExecutor.java:345) at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.fail(DependencyWaiterApplicationContextExecutor.java:401) at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:287) at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:175) at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:175) at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:718) at java.lang.Thread.run(Thread.java:636)

Carla Brian replied on Sat, 2012/06/30 - 11:12am

 Fuse ESB has a pluggable architecture that allows organizations to use their preferred service solutions in their SOA. - Mercy Ministries

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.