Chapter 8. ActiveMQ Brokers and Clusters
fabric:mq-createcommand to create and deploy clusters of brokers.
8.1. Creating a Single Broker Instance
- 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
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
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.
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
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).
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
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
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.
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.
--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”.