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.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 5. Clustering JBI Endpoints
Overview Copier lienLien copié sur presse-papiers!
Features Copier lienLien copié sur presse-papiers!
- 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 Copier lienLien copié sur presse-papiers!
- 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”.
Installing the clustering feature Copier lienLien copié sur presse-papiers!
- 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.
Default clustering engine configuration Copier lienLien copié sur presse-papiers!
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
.
Example 5.1. Default cluster engine configuration
Changing the default configuration Copier lienLien copié sur presse-papiers!
org.apache.servicemix.jbi.cluster.config
. This added configuration file enables you to change both the clusterName
and the destinationName
.
Changing the JMS broker Copier lienLien copié sur presse-papiers!
InstallDir\deploy
directory.
Using clustering in an application Copier lienLien copié sur presse-papiers!
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>
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 Copier lienLien copié sur presse-papiers!
- 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
High availability Copier lienLien copié sur presse-papiers!
ACTIVE
mode and the slave is in STANDBY
mode waiting for a failover event to trigger the slave to take over.
- 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 Copier lienLien copié sur presse-papiers!
- 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