Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Chapter 5. Clustering JBI Endpoints
Important
The Java Business Integration components of Red Hat JBoss Fuse are considered deprecated. You should consider migrating any JBI applications to OSGi.
Overview Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Red Hat JBoss Fuse provides a clustering engine that enables you to use Apache ActiveMQ, or any other JMS broker, to specify the endpoints to cluster in a JBI application. The Red Hat JBoss Fuse clustering engine works in conjunction with the normalized message router (NMR), and uses Apache ActiveMQ and specifically configured JBI endpoints to build clusters.
A cluster is defined as two or more JBI containers networked together. Implementing clustering between JBI containers gives you access to features including load balancing and high availability, rollback and redelivery, and remote container awareness.
Features Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Clustering provides the following features that can be implemented in your applications:
- Connect JBI containers to form a network, and dynamically add and remove the containers from the network.
- Enable rollback and redelivery when a JBI exchange fails.
- Implement load balancing among JBI containers capable of handling a given exchange. For example:
- Install the same component in multiple JBI containers to provide increased capacity and high availability (if one container fails, the same component in another container can service the request).
- Partition the workload among multiple JBI container instances to enable different containers to handle different tasks, spreading the workload across multiple containers.
- Remote component awareness means each clustered JBI container is aware of the components in its peer containers. Networked containers listen for remote component registration/deregistration events and can route requests to those components.
Steps to set up clustering Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Complete the following steps to set up JBI endpoint clustering:
- Install the jbi-cluster feature included in Red Hat JBoss Fuse. See the section called “Installing the clustering feature”.
- Optionally, configure the clustering engine with a JMS broker other than the Red Hat JBoss A-MQ. See the section called “Changing the JMS broker”.
- Optionally, change the default clustering engine configuration to specify different cluster and destination names. See the section called “Changing the default configuration”.
- Add endpoints and register the endpoint definition in the Spring configuration. See the section called “Using clustering in an application”.
See the following sections for additional information:
Installing the clustering feature Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To install the jbi-cluster feature, use the install command from the command console:
- Start Red Hat JBoss Fuse.
- At the
JBossFuse:karaf@root>
prompt, type:features:install jbi-cluster
- Type
featuresL:list
to list the existing features and their installation state. Verify that the jbi-cluster feature is installed.
The cluster configuration bundle is automatically installed when you install the jbi-cluster feature.
Default clustering engine configuration Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Red Hat JBoss Fuse has a pre-installed clustering engine that is configured to use the included Red Hat JBoss A-MQ. The default configuration for the Red Hat JBoss Fuse cluster engine is defined in the
jbi-cluster.xml
file in the org.apache.servicemix.jbi.cluster.config
bundle. This bundle is located in the installation directory in \system\org\apache\servicemix\jbi\cluster
.
The default cluster engine configuration, shown in Example 5.1, is designed to meet most basic requirements.
Example 5.1. Default cluster engine configuration
Red Hat JBoss Fuse has a preconfigured Red Hat JBoss A-MQ instance that automatically starts when the container is started. This means you do not have to start a broker instance for the clustering engine to work.
Changing the default configuration Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
You can alter the default configuration by adding a configuration file to the bundle
org.apache.servicemix.jbi.cluster.config
. This added configuration file enables you to change both the clusterName
and the destinationName
.
Changing the JMS broker Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
You can configure the cluster engine with another JMS broker by adding a Spring XML file containing the full configuration to the
InstallDir\deploy
directory.
Using clustering in an application Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
When using an OSGi packaged JBI service assembly, you can include the clustered endpoints definitions directly in the Spring configuration. In addition to the endpoint definition, you must add a bean that registers the endpoint with the clustering engine.
Example 5.2 shows an OSGi packaged HTTP consumer endpoint that is part of a cluster.
Example 5.2. OSGi packaged JBI endpoint
<http:consumer id="myHttpConsumer" service="test:myService" endpoint="myEndpoint" /> <bean class="org.apache.servicemix.jbi.cluster.engine.OsgiSimpleClusterRegistration"> <property name="endpoint" ref="myHttpConsumer" /> </bean>
<http:consumer id="myHttpConsumer" service="test:myService" endpoint="myEndpoint" />
<bean class="org.apache.servicemix.jbi.cluster.engine.OsgiSimpleClusterRegistration">
<property name="endpoint" ref="myHttpConsumer" />
</bean>
When using a JBI packaged service assembly, you must create a Spring application to register the endpoint as a clustered endpoint. This configuration requires that you provide additional information about the endpoint.
Example 5.3 shows a JBI packaged HTTP consumer endpoint that is part of a cluster.
Example 5.3. JBI packaged endpoint
<http:consumer id="myHttpConsumer" service="test:myService" endpoint="myEndpoint" /> <bean class="org.apache.servicemix.jbi.cluster.engine.OsgiSimpleClusterRegistration"> <property name="serviceName" value="test:myService" /> <property name="endpointName" value="myEndpoint" /> </bean>
<http:consumer id="myHttpConsumer" service="test:myService" endpoint="myEndpoint" />
<bean class="org.apache.servicemix.jbi.cluster.engine.OsgiSimpleClusterRegistration">
<property name="serviceName" value="test:myService" />
<property name="endpointName" value="myEndpoint" />
</bean>
Establishing network connections between containers Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To create a network of JBI containers, you must establish network connections between each of the containers in the network, and then establish a network connection between the active containers. You can configure these network connections as either static or multicast connections.
- Static network connections — Configure each
networkConnector
in the cluster in the broker configuration fileinstall_dir/conf/activemq.xml
.Example 5.4 shows an example of a staticnetworkConnector
discovery configuration.Example 5.4. Static configuration
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Multicast network connections — Enable multicast on your network and configure multicast in the broker configuration file
installation_directory/conf/activemq.xml
for each container in the network. When the containers start they detect each other and transparently connect to one another.Example 5.5 shows an example of a multicastnetworkConnector
discovery configuration.Example 5.5. Multicast configuration
<networkConnectors> <!-- by default just auto discover the other brokers --> <networkConnector name="default-nc" uri="multicast://default"/> </networkConnectors>
<networkConnectors> <!-- by default just auto discover the other brokers --> <networkConnector name="default-nc" uri="multicast://default"/> </networkConnectors>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
When a network connection is established, each container discovers the other containers' remote components and can route to them.
High availability Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
You can cluster JBI containers to implement high availability by configuring two distinct Red Hat JBoss Fuse container instances in a master-slave configuration. In all cases, the master is in
ACTIVE
mode and the slave is in STANDBY
mode waiting for a failover event to trigger the slave to take over.
You can configure the master and the slave one of the following ways:
- Shared file system master-slave — In a shared database master-slave configuration, two containers use the same physical data store for the container state. You should ensure that the file system supports file level locking, as this is the mechanism used to elect the master. If the master process exits, the database lock is released and the slave acquires it. The slave then becomes the master.
- JDBC master-slave — In a JDBC master-slave configuration, the master locks a table in the backend database. The failover event in this case is that the lock is released from the database.
- Pure master-slave — A pure master-slave configuration can use either a shared database or a shared file system. The master replicates all state changes to the slave so additional overhead is incurred. The failover trigger in a pure master-slave configuration is that the slave loses its network connection to its master. Because of the additional overhead and maintenance involved, this option is less desirable than the other two options.
Cluster configuration conventions Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The following conventions apply to configuring clustering:
- Don't use static and multicast
networkConnectors
at the same time. If you enable staticnetworkConnectors
, then you should disable any multicastnetworkConnectors
, and vice versa. - When configuring a network of containers in
installation_directory/conf/activemq.xml
, ensure that thebrokerName
attribute is unique for each node in the cluster. This will enable the instances in the network to uniquely identify each other. - When configuring a network of containers you must ensure that you have unique persistent stores for each
ACTIVE
instance. If you have a JDBC data source, you must use a separate database for eachACTIVE
instance. For example:<property name="url" value="jdbc:mysql://localhost/broker_activemq_host1?relaxAutoCommit=true"/>
<property name="url" value="jdbc:mysql://localhost/broker_activemq_host1?relaxAutoCommit=true"/>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - You can setup a network of containers on the same host. To do this, you must change the JMS ports and
transportConnector
ports to avoid any port conflicts. Edit theinstallation_directory/conf/activemq.xml
file, changing thermi.port
andactivemq.port
as appropriate. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow