Red Hat Training
A Red Hat training course is available for Red Hat Fuse
Chapter 8. ActiveMQ Brokers and Clusters
Fabric provides predefined profiles for deploying a single (unclustered) broker and, in addition, you can use the powerful
fabric:mq-createcommand to create and deploy clusters of brokers.
8.1. Creating a Single Broker Instance
The following profiles are important for creating broker instances:
- An abstract profile, which defines some important properties and resources for the broker, but should never be used directly to instantiate a broker.
- A basic single broker, which inherits most of its properties from the
To examine the properties defined in these profiles, you can invoke the
fabric:profile-displaycommand, as follows:
JBossFuse:karaf@root> fabric:profile-display mq-default ... JBossFuse:karaf@root> fabric:profile-display mq-base ...
Creating a new broker instance
A Fuse MQ broker is a Karaf container instance running a message broker profile. The profile defines the broker dependencies (through features) and the configuration for the broker. The simplest approach to creating a new broker is to use the provided
For example, to create a new
mq-defaultbroker instance called
broker1, enter the following console command:
JBossFuse:karaf@root> fabric:container-create-child --profile mq-default root broker1 Creating new instance on SSH port 8102 and RMI ports 1100/44445 at: /Users/jdoe/Downloads/jboss-fuse-6.3.0-254/instances/broker1 The following containers have been created successfully: Container: broker1.
This command creates a new container called
broker1with a broker of the same name running on it.
fabric:mq-createcommand provides a shortcut to creating a broker, but with more flexibility, because it also creates a new profile. To create a new broker instance called
fabric:mq-create, enter the following console command:
JBossFuse:karaf@root> fabric:mq-create --create-container broker --replicas 1 brokerx MQ profile mq-broker-default.brokerx ready
Just like the basic
fabric:mq-createcreates a container called
broker1and runs a broker instance on it. There are some differences, however:
- The new
broker1container is implicitly created as a child of the current container,
- The new broker has its own profile,
mq-broker-default.brokerx, which is based on the
- It is possible to edit the
mq-broker-default.brokerxprofile, to customize the configuration of this new broker.
--replicasoption lets you specify the number of master/slave broker replicas (for more details, see Section 8.3.2, “Master-Slave Cluster”). In this example, we specify one replica (the default is two).
The new profile gets the name
mq-broker-Group.BrokerNameby default. If you want the profile to have the same name as the broker (which was the default in JBoss Fuse version 6.0), you can specify the profile name explicitly using the
The new broker is created with SSL enabled by default. The initial certificates and passwords created by default are not secure, however, and must be replaced by custom certificates and passwords. See the section called “Customizing the SSL keystore.jks and truststore.jks file” for details of how to do this.
Starting a broker on an existing container
fabric:mq-createcommand can be used to deploy brokers on existing containers. Consider the following example, which creates a new Fuse MQ broker in two steps:
JBossFuse:karaf@root> fabric:container-create-child root broker1 Creating new instance on SSH port 8102 and RMI ports 1100/44445 at: /Users/jdoe/Downloads/jboss-fuse-6.3.0-254/instances/broker1 The following containers have been created successfully: broker1. JBossFuse:karaf@root> fabric:mq-create --assign-container broker1 brokerx MQ profile mq-broker-default.brokerx ready
The preceding example firstly creates a default child container, and then creates and deploys the new
mq-broker-default.brokerxprofile to the container, by invoking
--assign-containeroption. Of course, instead of deploying to a local child container (as in this example), we could assign the broker to an SSH container.
Brokers created using the
fabric:mq-createcommand are always registered with a specific broker group. If you do not specify the group name explicitly at the time you create the broker, the broker gets registered with the
defaultgroup by default.
If you like, you can specify the group name explicitly using the
--groupoption of the
fabric:mq-createcommand. For example, to create a new broker that registers with the
west-coastgroup, enter the following console command:
JBossFuse:karaf@root> fabric:mq-create --create-container broker --replicas 1 --group west-coast brokery MQ profile mq-broker-west-coast.brokery ready
west-coastgroup does not exist prior to running this command, it is automatically created by Fabric. Broker groups are important for defining clusters of brokers, providing the underlying mechanism for creating load-balancing clusters and master-slave clusters. For details, see Section 8.3, “Topologies”.