Lighting the fuse

Tutorial: Managing Apache ServiceMix clusters with Fuse Fabric

Torsten Mielke introduces some powerful OSGi and ESB concepts through the former FuseSource, now Red Hat led project 

Managing a large number of ServiceMix instances with dozens of applications deployed is a non trivial task, but open source project ServiceMix from Red Hat can help reduce the complexity of your application deployment.

Apache ServiceMix is quite a popular open source ESB that is best suited for Integration and SOA projects. It offers all the functionality one would expect from a commercial ESB – but in contrast to most commercial counterparts, at its core it is truly based on open standards and specifications .

ServiceMix leverages a number of very popular open source projects. Its excellent message routing capabilities are based on the Apache Camel framework. Apache Camel is a lightweight integration framework that uses standard Enterprise Integration Patterns (EIP) for defining integration routes using a variety of domain specific languages (DSL).

The majority of integration projects require a reliable messaging infrastructure. ServiceMix supports reliable messaging by embedding an Apache ActiveMQ message broker, which is one of the most popular, fully JMS 1.1 compliant open source message brokers. It offers a long list of messaging features, can be scaled to thousands of clients and supports many Clustering and High Availability broker topologies.

Support for Web Services and RESTful services is achieved by integrating Apache CXF. CXF is perhaps the most well known open source Web Services framework and has been fully integrated into ServiceMix. CXF supports both the JAX-WS and JAX-RS standard and all major WS-* specifications.

At the heart of ServiceMix is an OSGi container runtime. The OSGi Framework is responsible for loading and running truly dynamic software modules – so called OSGi bundles. An OSGi bundle is a plain Java jar file that contains additional OSGi specific meta data information about the classes and resources contained inside the jar.

The OSGi runtime used in ServiceMix is Apache Karaf, which offers many interesting features like hot deployment, dynamic configuration of OSGi bundles at runtime, a centralized logging system, remote management via JMX and an extensible shell console that can be used to manage all aspects of an OSGi runtime. Using Karaf one can manage all life cycle aspects of the deployed application modules individually. Karaf not only supports deploying OSGi bundles, but also plain Java jar files, Blueprint XML, Spring XML and war files. The flexible deployment options ease the migration of existing Java applications to OSGi.

ServiceMix deploys these open source projects out-of-the-box on top of the Karaf OSGi runtime. ActiveMQ and Camel register additional shell commands into the Karaf shell that can manage the embedded JMS broker and Camel environment at runtime. It’s also possible to only deploy those ESB functions that are needed for a particular project. If support for a certain element, for example Web Services, is not needed, the CXF related OSGi bundles can all be uninstalled. This further reduces the already small runtime memory footprint of ServiceMix. Figure 1 summarizes the technologies and standards that Apache ServiceMix is built on.

Figure 1: ESB enabling technologies in ServiceMix 

ServiceMix leverages a number of very successful open source projects. Each of these projects is based on open standards and industry specifications and designed to provide a maximum level of interoperability. All of these aspects make ServiceMix a very popular ESB that is deployed in thousands of customer sites today and in many mission critical applications. There is also professional, enterprise level support available from companies like Red Hat (who acquired FuseSource in 2012) and Talend.

Introduction to Fuse Fabric

It’s no surprise that some companies have dozens and even hundreds of ServiceMix instances deployed in their IT infrastructure. Larger projects may spawn multiple ServiceMix containers as one single JVM instance would not fit the entire application. In addition, the same application may be deployed to multiple ServiceMix containers for load balancing reasons. Each ServiceMix instance is an independent OSGi container with its own OSGi runtime and an individual set of deployed applications. However, managing a larger number of ServiceMix instances with dozens of applications deployed becomes a non trivial task as ServiceMix itself does not provide any tools to manage multiple ESB instances centrally.

Installing updates of an application deployed to multiple independent OSGi containers becomes a tedious and error-prone task. It is necessary to manually log into each OSGi container (e.g. using an ssh client session), stop the existing application, install and perhaps reconfigure the new version of the application and finally start the new application. These steps then need to be repeated on all the remaining ESB instances that run the same application. If anything goes wrong during such upgrade, changes need to be reverted back manually. This manual approach is cumbersome and chances are high that mistakes are made along the way.

Here, we can use Fuse Fabric, an open source Integration Platform under Apache license which began as a project within FuseSource. With Fuse Fabric you can group all ServiceMix container instances into one or several clusters, so called Fabrics. All instances of this cluster can then be managed from a central location, which potentially may be any ServiceMix instance within the Fabric. This includes both the configuration of all ESB instances in a cluster as well as the deployment of applications to each ServiceMix container.

Fabric extends the Karaf shell with additional commands for managing the cluster of OSGi containers, so users don't need to use another tool for managing the Fabric. It also supports deploying applications to both private and public clouds. Using the jclouds library, all major cloud providers are supported. Applications may be deployed to the cloud with a single Karaf shell command and even the virtual machine in the cloud can be started by Fabric.

Fabric can also create ESB containers on-demand. Not only can it create new ESB containers locally (sharing the existing installation of ServiceMix) but it can also start new ESB containers on remote machines that do not even have ServiceMix pre-installed. Using ssh, Fabric is capable of streaming a full ServiceMix installation to a remote machine, unpacking and starting that ServiceMix installation and provision it with pre-configured applications.

To better understand these features, let's have a look into the mechanisms and concepts used by Fabric.

Fabric concepts

Fabric defines a couple of components that work together to offer a centralized integration platform.

Each Fabric contains one or more Fabric Registries. A Fabric Registry is an Apache Zookeeper-based, distributed and highly-available configuration service which stores the complete configuration and deployment information of all ESB containers making up the cluster in a configuration registry.

The data is stored in a hierarchical tree-like structure inside Zookeeper. ESB containers get provisioned by Fabric based on the information stored in the configuration registry. There is also a runtime registry that stores details of the physical ESB instances making up the Fabric cluster, their physical locations and the services they are running. The runtime registry is used by clients to discover available services dynamically at runtime. The Fabric Registry can be made highly available by running replica instances. The example cluster in Figure 2 consists of three ESB instances that each run a registry replica.

Figure 2: A Fabric cluster consisting of 3 ESB instances, all running a Fabric Registry.

Fabric Registries store all configuration and deployment information of all ESB instances. This information is described in Fabric Profiles, where users fully describe their applications and the necessary configuration in these profiles. Profiles therefore become high level deployment units in Fabric and specify which OSGi bundles, plain Java jar or war files, what configuration and which Bundle Repositories a particular application or application module requires.

A Profile can be deployed to many ESB containers and each ESB container may deploy multiple profiles. Profiles are versioned, support inheritance relationships, and are managed using a set of Karaf shell commands. It is possible to describe common configuration or deployment information in a base profile that other more specific profiles inherit from.

Figure 3 shows some example profiles that are provided out-of-the-box. It defines a common base profile called default that all other profiles inherit from. The example also lists profiles named camel, mq or cxf. These profiles define the OSGi bundles and configuration for various ESB functions like message routing (based on Camel), reliable messaging (based on ActiveMQ) and Web Services support (based on CXF). Users are encouraged to create their own profile that inherit from these standard profiles.

Figure 3: Sample profiles

Profiles can be easily deployed to one or more ESB containers. Deploying a profile to a particular container is the task of the Fabric Agent. There is an agent running on each ESB container in the Fabric cluster. It connects to the Fabric Registry and evaluates the set of profiles it needs to deploy to its container. The agent further listens for changes to profile definitions and provisions the changes immediately to its container.

Finally Fabric defines the component of a Fabric Server or Fabric Container. This is every ESB container that is managed by Fabric. Each Fabric Server has a Fabric Agent running.

For true location transparency Fabric also defines a number of Fabric Extensions. Each CXF based Web Service, each Camel consumer endpoint (the start endpoint of a Camel integration route) and each ActiveMQ message broker instance can register its endpoint address in the Fabric runtime registry at start up. Clients can query the registry for these addresses at runtime rather than having the addresses hard-coded. This allows you to move endpoints to different physical machines at runtime, running replicas of endpoints for load balancing reasons, or even creating master/slave topologies where a slave endpoint (e.g. a slave message broker) waits on standby for the master endpoint to become unavailable. Fabric Extensions are outside the scope of this article but the link above explains them in full detail.

Fabric defines some really powerful concepts. All provisioning information is stored in a highly available Fabric Registry in form of Fabric profiles. These profiles can then be deployed quickly to any number of ESB instances inside the cluster thanks to the Fabric Agents. Also, Fabric is capable of creating new local and remote ESB instances on demand. Together with the Fabric Extensions this allows for very flexible deployments. If the load of a particular ESB container increases it is possible to start up another ESB container instance (perhaps in the cloud) that deploys the same set of applications and then load balance the overall work across all instances. Furthermore ESB instances can be moved to different physical servers if there is a need to run on faster hardware while clients automatically get rebalanced. With Fuse Fabric it is possible to quickly and easily adapt on any changes to your runtime requirements and have a fully flexible integration platform.

           

Pages

Torsten Mielke
Torsten Mielke

What do you think?

Comments

Latest opinions