Red Hat JBoss Fuse - Switchyard in OSGi
Red Hat JBoss Fuse - Switchyard in OSGi
Here's a guide to SwitchYard in OSGi, a framework for developing integration apps.
Join the DZone community and get the full member experience.Join For Free
So what exactly is SwitchYard? If you have ever played with JBoss Fuse Service Work, then you will probably know this already.
SwitchYard is a structured framework for developing integration applications using the design principles and best practices of Service Oriented Architecture.
It supports Service Component Architecture (SCA). SCA is basically a set of specifications. The specifications describe a model for building applications and systems using a Service-Oriented Architecture. By applying a standard way of describing the SOA's available components and services in an integration solution, we will then have an abstract layer of services that does not specifically belong to a single language or implementation. By implementing this standard, we will have a complete, well-defined SOA architecture.
In previous versions, one of the dividing factors between JBoss Fuse and JBoss Fuse Service Work is the containers where they run. JBoss FSW runs in JBoss EAP, which is the JavaEE container. JBoss Fuse runs on Karaf, the OSGi standard container. But now that Fuse can run on both JavaEE and OSGi, what about Switchyard? I can very happily tell you, YEP! It's OSGi ready now.
Let's take a look at Switchyard features that are available in JBoss Fuse server.
These are the basic switchyard features, and the libraries you will need.
These are the feature libraries of the components in Switchyard.
Then the rest of the features are quick starts and demos for you to play with.
Adding the required libraries into the container or adding them to your application profile will enable Switchyard running on Karaf.
Let's take one of the quick start demos, and see how to deploy it in a Karaf or Fabric environment in JBoss Fuse.
Karaf - Standalone OSGi container
Karaf is a simple and standalone OSGi container. It has fewer steps; basically, all we have to do is install the feature and then it's ready to go.
The list of repository URLs should already include JBoss Fuse. All we have to do is to install the demo feature.
This will download and install the feature and we can start to play with it.
Fuse Fabric - Set of Standalone Managed OSGi container
With Fuse Fabric, because we have another layer of control, namely the profile, we will need to first create a profile. (Make sure you have created your Fuse Fabric beforehand).
Create a small container for this small service.
Then we add the features we need in the profile, deploy the profile to an empty container, and then we are done!
profile-edit --features switchyard-quickstart-camel-cxf-binding demo-myswitchyard
Give the container a few minutes to download and install the bundles in the container, and type:
See if every container shows success in its status. For example:
JBossFuse:karaf@root> container-list [id] [version] [type] [connected] [profiles] [provision status] root* 1.0 karaf yes fabric success fabric-ensemble-0000-1 jboss-fuse-full mydemo 1.0 karaf yes default success
If this is what you see, then congratulations!!
This CXF binding demo is a very interesting example, as it shows usage of SOAP with Camel CXF component. The SwitchYard service binds to a CXF URL. We can call the service via the URL of the CXF component.
This demo is an order service. The order is sent by the client through the web service. The data is then sent to Camel, which routes the message to its destination, the warehouse service. The warehouse service then checks the inventory.
The switchyard.xml file, illustrated below, shows the architecture of the demo. The composite, which is the large blue rectangular shape base, defines the boundary of your application. Anything that is inside the rectangle is your application, and anything outside is an external resource. We see there are two endpoints exposed which allows resources to be called. We can also see an endpoint that calls an external resource.
In the middle you can see there are two Camel components. These components pass the message we got from the client, process it within the Camel route, then pass it out to the next step in SwitchYard. So how do we integrate Camel with SwitchYard? Simple, let's look at the Camel route here:
Notice some of the components started with SwitchYard? By creating a SwitchYard endpoint, you will be available to receive data from or produce data for your SwitchYard application.
To start the demo, simply run:
mvn exec:java -Pkaraf -Dexec
This will start the ClientProcessor in the project and send a SOAP message ordering Boeing with an amount of 10. Login in the to the console at http://localhost:8181/hawtio with your ID and password.
Click on the container we have just created.
It will take you to the container view, here you will be able to see what is happening.
What I love about this version of JBoss Fuse is that now you get to see all the routes at once.
Alright, that's all for this post. More about SwitchYard in the next one.
Published at DZone with permission of Christina Lin , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.