Red Hat AMQ 6
As of February 2025, Red Hat is no longer supporting Red Hat AMQ 6. If you are using AMQ 6, please upgrade: Migrating to AMQ 7.Fabric Guide
A system for provisioning containers deployed across a network
Copyright © 2011-2014 Red Hat, Inc. and/or its affiliates.
Abstract
Chapter 1. An Overview of Fuse Fabric Copy linkLink copied to clipboard!
Abstract
1.1. Concepts Copy linkLink copied to clipboard!
Fabric Copy linkLink copied to clipboard!
A sample fabric Copy linkLink copied to clipboard!
Figure 1.1. Containers in a Fabric
Registry Copy linkLink copied to clipboard!
- Configuration Registry—the logical configuration of your fabric, which typically contains no physical machine information. It contains details of the applications to be deployed and their dependencies.
- Runtime Registry—contains details of how many machines are actually running, their physical location, and what services they are implementing.
Fabric Ensemble Copy linkLink copied to clipboard!
Fabric Server Copy linkLink copied to clipboard!
Fabric Container (managed container) Copy linkLink copied to clipboard!
Fabric Agent Copy linkLink copied to clipboard!
Git Copy linkLink copied to clipboard!
Profile Copy linkLink copied to clipboard!
osgi:install or features:install, respectively), these modifications are impermanent. As soon as you restart the container or refresh its contents, the Fabric agent replaces the container's existing contents with whatever is specified by the deployed profiles.
1.2. Containers Copy linkLink copied to clipboard!
- Java processes running directly on hardware.
- A PaaS (Platform as a Service) such as OpenShift for either a public or private cloud.
- OpenStack as an IaaS (Infrastructure as a Service).
- Amazon Web Services, Rackspace or some other IaaS to manage services.
- Docker containers for each service.
- An open hybrid cloud composing all of the above entries.
1.3. Provisioning and Configuration Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Changing the configuration Copy linkLink copied to clipboard!
How discovery works Copy linkLink copied to clipboard!
Part I. Basic Fabric Deployment Copy linkLink copied to clipboard!
Abstract
Chapter 2. Getting Started with Fuse Fabric Copy linkLink copied to clipboard!
Abstract
2.1. Create a Fabric Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Figure 2.1. A Sample Fabric with Child Containers
Steps to create the fabric Copy linkLink copied to clipboard!
- To create the first fabric container, which acts as the seed for the new fabric, enter this console command:
JBossFuse:karaf@root> fabric:create --new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass --resolver manualip --manual-ip 127.0.0.1 --wait-for-provisioning
JBossFuse:karaf@root> fabric:create --new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass --resolver manualip --manual-ip 127.0.0.1 --wait-for-provisioningCopy to Clipboard Copied! Toggle word wrap Toggle overflow The current container, namedrootby default, becomes a Fabric Server with a registry service installed. Initially, this is the only container in the fabric. The--new-userand--new-user-passwordoptions specify the credentials for a new administrator user. The Zookeeper password is used to protect sensitive data in the Fabric registry service (all of the nodes under/fabric). The--manual-ipoption specifies the loopback address,127.0.0.1, as the Fabric Server's IP address.NoteA Fabric Server requires a static IP address. For simple trials and tests, you can use the loopback address,127.0.0.1, to work around this requirement. But if you are deploying a fabric in production or if you want to create a distributed ensemble, you must assign a static IP address to the each of the Fabric Server hosts.NoteMost of the time, you are not prompted to enter the Zookeeper password when accessing the registry service, because it is cached in the current session. When you join a container to a fabric, however, you must provide the fabric's Zookeeper password. - Create a child container. Assuming that your root container is named
root, enter this console command:JBossFuse:karaf@root> fabric:container-create-child root child The following containers have been created successfully: Container: child.
JBossFuse:karaf@root> fabric:container-create-child root child The following containers have been created successfully: Container: child.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Invoke the following command to monitor the status of the child container, as it is being provisioned:
JBossFuse:karaf@root> shell:watch container-list
JBossFuse:karaf@root> shell:watch container-listCopy to Clipboard Copied! Toggle word wrap Toggle overflow After the deployment of thechildhas completed, you should see a listing something like this:JBossFuse:karaf@root> shell:watch container-list [id] [version] [alive] [profiles] [provision status] root 1.0 true fabric, fabric-ensemble-0000-1, fuse-esb-full success child 1.0 true default success
JBossFuse:karaf@root> shell:watch container-list [id] [version] [alive] [profiles] [provision status] root 1.0 true fabric, fabric-ensemble-0000-1, fuse-esb-full success child 1.0 true default successCopy to Clipboard Copied! Toggle word wrap Toggle overflow Type theReturnkey to get back to the JBoss Fuse console prompt.
2.2. Deploy a Profile Copy linkLink copied to clipboard!
Deploy a profile to the child container Copy linkLink copied to clipboard!
- Deploy the
example-camel-helloprofile into thechildcontainer by entering this console command:JBossFuse:karaf@root> fabric:container-change-profile child example-camel-hello
JBossFuse:karaf@root> fabric:container-change-profile child example-camel-helloCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Verify that the
example-camel-helloprofile deploys successfully to thechildcontainer, using thefabric:container-listcommand. Enter the following command to monitor the container status:JBossFuse:karaf@root> shell:watch container-list
JBossFuse:karaf@root> shell:watch container-listCopy to Clipboard Copied! Toggle word wrap Toggle overflow And wait until thechildcontainer status changes tosuccess.
View the sample output Copy linkLink copied to clipboard!
example-camel-hello profile writes a message to the container's log every five seconds. To verify that the profile is running properly, you can look for these messages in the child container's log, as follows:
- Connect to the
childcontainer, by entering the following console command:JBossFuse:karaf@root> container-connect child
JBossFuse:karaf@root> container-connect childCopy to Clipboard Copied! Toggle word wrap Toggle overflow - After logging on to the
childcontainer, view thechildcontainer's log using thelog:tailcommand, as follows:JBossFuse:karaf@root> log:tail
JBossFuse:karaf@root> log:tailCopy to Clipboard Copied! Toggle word wrap Toggle overflow You should see some output like the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Type Ctrl-C to exit the log view and get back to the child container's console prompt.
2.3. Update a Profile Copy linkLink copied to clipboard!
Atomic container upgrades Copy linkLink copied to clipboard!
Profile versioning Copy linkLink copied to clipboard!
Upgrade to a new profile Copy linkLink copied to clipboard!
example-camel-hello profile, when it is deployed and running in a container, follow the recommended procedure:
- Create a new version, 1.1, to hold the pending changes by entering this console command:
JBossFuse:karaf@root> fabric:version-create Created version: 1.1 as copy of: 1.0
JBossFuse:karaf@root> fabric:version-create Created version: 1.1 as copy of: 1.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow The new version is initialised with a copy of all of the profiles from version 1.0. - Use the
fabric:profile-editcommand to change the message that is written to the container log by the Camel route. Enter the followingprofile-editcommand to edit thecamel.xmlresource:JBossFuse:karaf@root> fabric:profile-edit --resource camel.xml example-camel-hello 1.1
JBossFuse:karaf@root> fabric:profile-edit --resource camel.xml example-camel-hello 1.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow This opens the built-in text editor for editing profile resources (see Appendix A, Editing Profiles with the Built-In Text Editor).Remember to specify version1.1to thefabric:profile-editcommand, so that the modifications are applied to version 1.1 of theexample-camel-helloprofile. - Upgrade the
childcontainer to version1.1by entering this console command:JBossFuse:karaf@root> fabric:container-upgrade 1.1 child
JBossFuse:karaf@root> fabric:container-upgrade 1.1 childCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Roll back to an old profile Copy linkLink copied to clipboard!
example-camel-hello profile, using the fabric:container-rollback command like this:
JBossFuse:karaf@root> fabric:container-rollback 1.0 child
JBossFuse:karaf@root> fabric:container-rollback 1.0 child
2.4. Shutting Down the Containers Copy linkLink copied to clipboard!
Shutting down the containers Copy linkLink copied to clipboard!
fabric:container-stop command. For example, to shut down the current fabric completely, enter these console commands:
JBossFuse:karaf@root> fabric:container-stop child JBossFuse:karaf@root> shutdown -f
JBossFuse:karaf@root> fabric:container-stop child
JBossFuse:karaf@root> shutdown -f
fabric:container-start console command.
Chapter 3. Creating a New Fabric Copy linkLink copied to clipboard!
Abstract
Static IP address required for Fabric Server Copy linkLink copied to clipboard!
- For simple examples and tests (with a single Fabric Server) you can work around the static IP requirement by using the loopback address,
127.0.0.1. - For distributed tests (multiple Fabric Servers) and production deployments, you must assign a static IP address to each of the Fabric Server hosts.
--resolver manualip --manual-ip StaticIPAddress options to specify the static IP address explicitly, when creating a new Fabric Server.
Procedure Copy linkLink copied to clipboard!
- (Optional) Customise the name of the root container by editing the
InstallDir/etc/system.propertiesfile and specifying a different name for this property:karaf.name=root
karaf.name=rootCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteFor the first container in your fabric, this step is optional. But at some later stage, if you want to join a root container to the fabric, you might need to customise the container's name to prevent it from clashing with any existing root containers in the fabric. - Any existing users in the
InstallDir/etc/users.propertiesfile are automatically used to initialize the fabric's user data, when you create the fabric. You can populate theusers.propertiesfile, by adding one or more lines of the following form:Username=Password[,RoleA][,RoleB]...
Username=Password[,RoleA][,RoleB]...Copy to Clipboard Copied! Toggle word wrap Toggle overflow But there must not be any users in this file that have theadminrole. If theInstallDir/etc/users.propertiesalready contains users with theadminrole, you should delete those users before creating the fabric.WarningIf you leave some administrator credentials in theusers.propertiesfile, this represents a security risk because the file could potentially be accessed by other containers in the fabric.NoteThe initialization of user data fromusers.propertieshappens only once, at the time the fabric is created. After the fabric has been created, any changes you make tousers.propertieswill have no effect on the fabric's user data. - If you use a VPN (virtual private network) on your local machine, it is advisable to log off VPN before you create the fabric and to stay logged off while you are using the local container.NoteA local Fabric Server is permanently associated with a fixed IP address or hostname. If VPN is enabled when you create the fabric, the underlying Java runtime is liable to detect and use the VPN hostname instead of your permanent local hostname. This can also be an issue with multi-homed machines.
- Start up your local container.In JBoss A-MQ, start the local container as follows:
cd InstallDir/bin ./amq
cd InstallDir/bin ./amqCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIf you want to create a fabric on a remote container, you can log into it using theInstallDir/bin/clientcommand-line utility. - Create a new fabric by entering the following command:
JBossFuse:karaf@root> fabric:create --new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass --resolver manualip --manual-ip StaticIPAddress --wait-for-provisioning
JBossFuse:karaf@root> fabric:create --new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass --resolver manualip --manual-ip StaticIPAddress --wait-for-provisioningCopy to Clipboard Copied! Toggle word wrap Toggle overflow The current container, namedrootby default, becomes a Fabric Server with a registry service installed. Initially, this is the only container in the fabric. The--new-userand--new-user-passwordoptions specify the credentials for a new administrator user. The Zookeeper password is used to protect sensitive data in the Fabric registry service (all of the nodes under/fabric). The--manual-ipoption specifies the Fabric Server's static IP addressStaticIPAddress(see the section called “Static IP address required for Fabric Server”).For more details on fabric:create see section "Description" in "Console Reference"section "Description" in "Console Reference".
Fabric creation process Copy linkLink copied to clipboard!
- The container installs the requisite OSGi bundles to become a Fabric Server.
- The Fabric Server starts a registry service, which listens on IP port 2181 (which makes fabric configuration data available to all of the containers in the fabric).
- The Fabric Server installs a new JAAS realm (based on the ZooKeeper login module), which overrides the default JAAS realm and stores its user data in the ZooKeeper registry.
- The new Fabric Ensemble consists of a single Fabric Server (the current container).
- A default set of profiles is imported from
InstallDir/fabric/import(can optionally be overridden). - After the standalone container is converted into a Fabric Server, the previously installed OSGi bundles and Karaf features are completely cleared away and replaced by the default Fabric Server configuration. For example, some of the shell command sets that were available in the standalone container are no longer available in the Fabric Server.
Expanding a Fabric Copy linkLink copied to clipboard!
- Child container, created on the local machine as a child process in its own JVM.Instructions on creating a child container are found in Child Containers.
- SSH container, created on any remote machine for which you have
sshaccess.Instructions on creating a SSH container are found in SSH Containers. - Cloud container, created on compute instance in the cloud.Instructions on creating a cloud container are found in Cloud Containers.
Chapter 4. Fabric Containers Copy linkLink copied to clipboard!
4.1. Child Containers Copy linkLink copied to clipboard!
Abstract
Overview Copy linkLink copied to clipboard!
One container or many? Copy linkLink copied to clipboard!
Creating a child container Copy linkLink copied to clipboard!
fabric:container-create-child command, specifying the parent container name and the name of the new child container. For example, to create the new child container, onlychild, with root as its parent, enter the following command:
fabric:container-create-child root onlychild
fabric:container-create-child root onlychild
fabric:container-create-child root child 3
fabric:container-create-child root child 3
child1 child2 child3
child1
child2
child3
Stopping and starting a child container Copy linkLink copied to clipboard!
fabric:container-stop command. For example, to shut down the child1 container:
fabric:container-stop child1
fabric:container-stop child1
fabric:container-start command, as follows:
fabric:container-start child1
fabric:container-start child1
ps and kill.
Deleting a child container Copy linkLink copied to clipboard!
fabric:container-delete command, as follows:
fabric:container-delete child1
fabric:container-delete child1
4.2. SSH Containers Copy linkLink copied to clipboard!
Abstract
Overview Copy linkLink copied to clipboard!
Prerequisites Copy linkLink copied to clipboard!
- Linux or UNIX operating system,
- SSHD running on the target host and:
- A valid account credentials, or
- Configured public key authentication
- Java 1.6 installed.
- Curl installed.
- GNU tar installed.
- Telnet installed.
Creating an SSH container Copy linkLink copied to clipboard!
fabric:container-create-ssh console command, for creating SSH containers.
myhost (accessible from the local network) with the SSH user account, myuser, and the password, mypassword, your could create an SSH container on myhost, using the following console command:
fabric:container-create-ssh --host myhost --user myuser --password mypassword myremotecontainername
fabric:container-create-ssh --host myhost --user myuser --password mypassword myremotecontainername
myuser user on myhost has configured public key authentication for SSH, you can skip the password option:
fabric:container-create-ssh --host myhost --user myuser myremotecontainername
fabric:container-create-ssh --host myhost --user myuser myremotecontainername
~/.ssh/id_rsa for authentication. If you need to use a different key, you can specify the key location explicitly with the --private-key option:
fabric:container-create-ssh --host myhost --user myuser --private-key ~/.ssh/fabric_pk myremotecontainername
fabric:container-create-ssh --host myhost --user myuser --private-key ~/.ssh/fabric_pk myremotecontainername
--pass-phrase option, in case your key requires a pass phrase.
Creating a Fabric server using SSH Copy linkLink copied to clipboard!
fabric:container-create-ssh supports the --ensemble-server option, which can be invoked to create a container which is a Fabric server. For example, the following container-create-ssh command creates a new fabric consisting of one Fabric server on the myhost host:
fabric:container-create-ssh --host myhost --user myuser --ensemble-server myremotecontainername fabric:join myhost:2181
fabric:container-create-ssh --host myhost --user myuser --ensemble-server myremotecontainername
fabric:join myhost:2181
fabric:join command joins the current container to the new fabric. This has the advantage that it is much easier to administer the new fabric using a container that is joined to the fabric, because the local container then gains access to the connection data stored in the Fabric registry.
fabric:join is the ZooKeeper server port, Host:Port. The port number in this example, 2181, is the standard ZooKeeper port number in Fabric.
fabric:join command, you will be prompted to enter the ZooKeeper password for the fabric.
Managing remote SSH containers Copy linkLink copied to clipboard!
fabric:container-stop myremotecontainername
fabric:container-stop myremotecontainername
fabric:container-start myremotecontainername
fabric:container-start myremotecontainername
fabric:container-delete myremotecontainername
fabric:container-delete myremotecontainername
References Copy linkLink copied to clipboard!
4.3. Fabric Containers on Windows Copy linkLink copied to clipboard!
Abstract
Overview Copy linkLink copied to clipboard!
Creating a Fabric container on Windows Copy linkLink copied to clipboard!
- Following the instructions in the JBoss Fuse Installation Guide, manually install the JBoss Fuse product on the Windows target host.
- Open a new command prompt and enter the following commands to start the container on the target host:
cd InstallDir\bin fuse.bat
cd InstallDir\bin fuse.batCopy to Clipboard Copied! Toggle word wrap Toggle overflow - If the Fabric servers from the Fabric ensemble are not already running, start them now.
- Join the container to the existing fabric, by entering the following console command:
JBossFuse:karaf@root> fabric:join --zookeeper-password ZooPass RegistryHost
JBossFuse:karaf@root> fabric:join --zookeeper-password ZooPass RegistryHostCopy to Clipboard Copied! Toggle word wrap Toggle overflow WhereZooPassis the ZooKeeper password for the Fabric ensemble (as specified when you originally created the fabric withfabric:create); andRegistryHostis the hostname or IP address of one of the hosts where a Fabric server is running.NoteBy default, Fabric uses the default IP port number,2181, to connect to the Fabric server on theRegistryHosthost. If, for some reason, the ZooKeeper service is listening on a different IP port, you can specify the IP port number explicitly using the syntax,RegistryHost:RegistryIPPort.
default profile deployed on it.
Creating a Fabric server on Windows Copy linkLink copied to clipboard!
- Following the instructions in the JBoss Fuse Installation Guide, manually install the JBoss Fuse product on the Windows target host.
- To start the container on the target host, open a new command prompt and enter the following commands:
cd InstallDir\bin fuse.bat
cd InstallDir\bin fuse.batCopy to Clipboard Copied! Toggle word wrap Toggle overflow - To create a new fabric (thereby turning the current host into a Fabric server), enter the following console command:
fabric:create --new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass --resolver manualip --manual-ip StaticIPAddress --wait-for-provisioning
fabric:create --new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass --resolver manualip --manual-ip StaticIPAddress --wait-for-provisioningCopy to Clipboard Copied! Toggle word wrap Toggle overflow The current container, namedrootby default, becomes a Fabric Server with a registry service installed. Initially, this is the only container in the fabric. The--new-userand--new-user-passwordoptions specify the credentials for a new administrator user. The Zookeeper password is used to protect sensitive data in the Fabric registry service (all of the nodes under/fabric). The--manual-ipoption specifies the Fabric Server's static IP addressStaticIPAddress(see the section called “Static IP address required for Fabric Server”).
Managing remote containers on Windows Copy linkLink copied to clipboard!
fabric:join), there are certain restrictions on which commands you can use to manage it. In particular, the following commands are not supported:
fabric:container-stop fabric:container-start fabric:container-delete
fabric:container-stop
fabric:container-start
fabric:container-delete
4.4. Cloud Containers Copy linkLink copied to clipboard!
Abstract
4.4.1. Preparing to use Fabric in the Cloud Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Prerequisites Copy linkLink copied to clipboard!
- A valid account with one of the cloud providers implemented by JClouds. The list of cloud providers can be found at JClouds supported providers.NoteIn the context of JClouds, the term supported provider does not imply commercial support for the listed cloud providers. It just indicates that there is an available implementation.
Hybrid clusters Copy linkLink copied to clipboard!
- Fabric registry is running inside the public cloud.In this case, local containers will have no problem accessing the registry, as long as they are able to connect to the Internet.
- Cloud and local containers are part of a Virtual Private Network (VPN).If the Fabric registry is running on the premises, the cloud containers will not be able to access the registry, unless you set up a VPN (or make the registry accessible from the Internet, which is not recommended).
- Fabric registry is accessible from the Internet (not recommended).
Preparation Copy linkLink copied to clipboard!
fabric:create command. You cannot access the requisite cloud console commands until you create a Fabric locally.
JBossFuse:karaf@root> fabric:create --new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass --wait-for-provisioning
JBossFuse:karaf@root> fabric:create --new-user AdminUser --new-user-password AdminPass
--zookeeper-password ZooPass --wait-for-provisioning
--new-user and --new-user-password options specify the credentials for a new administrator user. The ZooPass password specifies the password that is used to protect the Zookeeper registry.
cloud-aws.ec2 profile, as follows:
fabric:container-add-profile root cloud-aws.ec2
fabric:container-add-profile root cloud-aws.ec2
root is the name of your local container.
Feature naming convention Copy linkLink copied to clipboard!
cloud-aws.ec2 profile is the jclouds-aws-ec2 feature, which provides the necessary bundles for interacting with Amazon EC2:
jclouds-aws-ec2- Feature for the Amazon EC2 cloud provider.
jclouds-cloudservers-us- Feature for the Rackspace cloud provider.
jclouds-ProviderID, where ProviderID is one of the provider IDs listed in the JClouds supported providers page. Or you can list the available JClouds features using the features:list command:
features:list | grep jclouds
features:list | grep jclouds
fabric:profile-edit --features jclouds-ProviderID MyProfile fabric:container-add-profile root MyProfile
fabric:profile-edit --features jclouds-ProviderID MyProfile
fabric:container-add-profile root MyProfile
Registering a cloud provider Copy linkLink copied to clipboard!
fabric:cloud-service-add console command (the registration process will store the provider credentials in the Fabric registry, so that they are available from any Fabric container).
fabric:cloud-service-add --name aws-ec2 --provider aws-ec2 --identity AccessKeyID --credential SecretAccessKey
fabric:cloud-service-add --name aws-ec2 --provider aws-ec2
--identity AccessKeyID --credential SecretAccessKey
--name option is an alias that you use to refer to this registered cloud provider instance. It is possible to register the same cloud provider more than once, with different user accounts. The cloud provider alias thus enables you distinguish between multiple accounts with the same cloud provider.
4.4.2. Administering Cloud Containers Copy linkLink copied to clipboard!
Creating a new fabric in the cloud Copy linkLink copied to clipboard!
fabric:container-create-cloud with the --ensemble-server option, which creates a new Fabric server. For example, to create a Fabric server on Amazon EC2:
fabric:container-create-cloud --ensemble-server --name aws-ec2 --new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass mycontainer
fabric:container-create-cloud --ensemble-server --name aws-ec2
--new-user AdminUser --new-user-password AdminPass --zookeeper-password ZooPass mycontainer
Basic security Copy linkLink copied to clipboard!
fabric:container-create-cloud command, to ensure that the new fabric is adequately protected. You need to specify the following security data:
- JAAS credentials—the
--new-userand--new-user-passwordoptions define JAAS credentials for a new user with administrative privileges on the fabric. These credentials can subsequently be used to log on to the JMX port or the SSH port of the newly created Fabric server. - ZooKeeper password—is used to protect the data stored in the ZooKeeper registry in the Fabric server. The only time you will be prompted to enter the ZooKeeper password is when you try to join a container to the fabric using the
fabric:joincommand.
Joining a standalone container to the fabric Copy linkLink copied to clipboard!
fabric:join -n --zookeeper-password ZooPass PublicIPAddress
fabric:join -n --zookeeper-password ZooPass PublicIPAddress
PublicIPAddress is the public host name or the public IP address of the compute instance that hosts the Fabric server (you can get this address either from the JBoss Fuse console output or from the Amazon EC2 console).
Creating a cloud container Copy linkLink copied to clipboard!
fabric:container-create-cloud command to create new Fabric containers in the cloud. For example to create a container on Amazon EC2:
fabric:container-create-cloud --name aws-ec2 mycontainer
fabric:container-create-cloud --name aws-ec2 mycontainer
fabric:container-create-cloud command with the --os-family option as follows:
fabric:container-create-cloud --name aws-ec2 --os-family centos mycontainer
fabric:container-create-cloud --name aws-ec2 --os-family centos mycontainer
--os-version option:
fabric:container-create-cloud --name aws-ec2 --os-family centos --os-version 5 mycontainer
fabric:container-create-cloud --name aws-ec2 --os-family centos --os-version 5 mycontainer
--image option.
fabric:container-create-cloud --name aws-ec2 --image myimageid mycontainer
fabric:container-create-cloud --name aws-ec2 --image myimageid mycontainer
Images Copy linkLink copied to clipboard!
- Linux O/S
- RedHat or Debian packaging style
- Either no Java installed or Java 1.6+ installed. If there is no Java installed on the image, Fabric will install Java for you. If the wrong Java version is installed, however, the container installation will fail.
fabric:cloud-service-add --name aws-ec2 --provider aws-ec2 --identity AccessKeyID --credential SecretAccessKey --owner myownerid
fabric:cloud-service-add --name aws-ec2 --provider aws-ec2
--identity AccessKeyID --credential SecretAccessKey --owner myownerid
Locations and hardware Copy linkLink copied to clipboard!
jclouds:location-list
jclouds:location-list
jclouds:hardware-list
jclouds:hardware-list
fabric:container-create-cloud command. For example:
fabric:container-create-cloud --name aws-ec2 --location eu-west-1 --hardware m2.4xlarge mycontainer
fabric:container-create-cloud --name aws-ec2 --location eu-west-1 --hardware m2.4xlarge mycontainer
Chapter 5. Fabric Profiles Copy linkLink copied to clipboard!
Abstract
5.1. Introduction to Profiles Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
What is in a profile? Copy linkLink copied to clipboard!
- OSGi bundle URLs
- Web ARchive (WAR) URLs
- Fuse Application Bundle (FAB) URLs
- OSGi Configuration Admin PIDs
- Apache Karaf feature repository URLs
- Apache Karaf features
- Maven artifact repository URLs
- Blueprint XML files or Spring XML files (for example, for defining broker configurations or Camel routes)
- Any kind of resource that might be needed by an application (for example, Java properties file, JSON file, XML file, YML file)
- System properties that affect the Apache Karaf container (analogous to editing
etc/config.properties) - System properties that affect installed bundles (analogous to editing
etc/system.properties)
Profile hierarchies Copy linkLink copied to clipboard!
Some basic profiles Copy linkLink copied to clipboard!
- [default]
- The
defaultprofile defines all of the basic requirements for a Fabric container. For example it specifies thefabric-agentfeature, the Fabric registry URL, and the list of Maven repositories from which artifacts can be downloaded. - [karaf]
- Inherits from the
defaultprofile and defines the Karaf feature repositories, which makes the Apache Karaf features accessible. - [feature-camel]
- Inherits from
karaf, defines the Camel feature repositories, and installs some core Camel features: such ascamel-coreandcamel-blueprint. If you are deploying a Camel application, it is recommended that you inherit from this profile. - [feature-cxf]
- Inherits from
karaf, defines the CXF feature repositories, and installs some core CXF features. If you are deploying a CXF application, it is recommended that you inherit from this profile. - [mq-base]
- Inherits from the
karafprofile and installs themq-fabricfeature - [mq-default]
- Inherits from the
mq-baseprofile and provides the configuration for an A-MQ broker. Use this profile, if you want to deploy a minimal installation of an ActiveMQ broker. - [jboss-fuse-minimal]
- Includes all of the features and bundles required for the JBoss Fuse minimal container.
- [jboss-fuse-medium]
- Includes all of the features and bundles required for the JBoss Fuse medium container.
- [jboss-fuse-full]
- Includes all of the features and bundles required for the JBoss Fuse full container.
5.2. Working with Profiles Copy linkLink copied to clipboard!
Changing the profiles in a container Copy linkLink copied to clipboard!
fabric:container-change-profile command as follows:
fabric:container-change-profile mycontainer myprofile
fabric:container-change-profile mycontainer myprofile
myprofile profile to the mycontainer container. All profiles previously assigned to the container are removed. You can also deploy multiple profiles to the container, with the following command:
fabric:container-change-profile mycontainer myprofile myotherprofile
fabric:container-change-profile mycontainer myprofile myotherprofile
Adding a profile to a container Copy linkLink copied to clipboard!
fabric:container-add-profile command gives you a simple way to add profiles to a container, without having to list all of the profiles that were already assigned. For example, to add the example-camel profile to the mycontainer container:
fabric:container-add-profile mycontainer example-camel
fabric:container-add-profile mycontainer example-camel
Listing available profiles Copy linkLink copied to clipboard!
fabric:profile-list console command:
fabric:profile-list
fabric:profile-list
Inspecting profiles Copy linkLink copied to clipboard!
fabric:profile-display command. For example, to display what is defined in the feature-camel profile, enter the following command:
fabric:profile-display feature-camel
fabric:profile-display feature-camel
feature-camel profile, taking into account all of its ancestors, you must specify the --overlay switch, as follows:
fabric:profile-display --overlay feature-camel
fabric:profile-display --overlay feature-camel
--display-resources switch (or -r for short) to the profile-display command, as follows:
fabric:profile-display -r feature-camel
fabric:profile-display -r feature-camel
Creating a new profile Copy linkLink copied to clipboard!
fabric:profile-create command, as follows:
fabric:profile-create myprofile
fabric:profile-create myprofile
--parents option to the command:
fabric:profile-create --parents feature-camel myprofile
fabric:profile-create --parents feature-camel myprofile
Adding or removing features Copy linkLink copied to clipboard!
fabric:profile-edit command. For example, to add the camel-jclouds feature to the feature-camel profile.
fabric:profile-edit --features camel-jclouds feature-camel
fabric:profile-edit --features camel-jclouds feature-camel
fabric:profile-display command to see what the camel profile looks like now. You should see that the camel-jclouds feature appears in the list of features for the feature-camel profile.
Features :
camel-jclouds
camel-blueprint/2.9.0.fuse-7-061
camel-core/2.9.0.fuse-7-061
fabric-camel/99-master-SNAPSHOT
Features :
camel-jclouds
camel-blueprint/2.9.0.fuse-7-061
camel-core/2.9.0.fuse-7-061
fabric-camel/99-master-SNAPSHOT
--delete option. For example, if you need to remove the camel-jclouds feature, you could use the following command:
fabric:profile-edit --delete --features camel-jclouds feature-camel
fabric:profile-edit --delete --features camel-jclouds feature-camel
Editing PID properties Copy linkLink copied to clipboard!
- Edit the PID using the built-in text editor—the Karaf console has a built-in text editor which you can use to edit profile resources such as PID properties. To start editing a PID using the text editor, enter the following console command:
fabric:profile-edit --pid PID ProfileName
fabric:profile-edit --pid PID ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more details about the built-in text editor, see Appendix A, Editing Profiles with the Built-In Text Editor. - Edit the PID inline, using console commands—alternatively, you can edit PIDs directly from the console, using the appropriate form of the
fabric:profile-editcommand. This approach is particularly useful for scripting. For example, to set a specific key-value pair,Key=Value, in a PID, enter the following console command:fabric:profile-edit --pid PID/Key=Value ProfileName
fabric:profile-edit --pid PID/Key=Value ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Editing a PID inline Copy linkLink copied to clipboard!
fabric:profile-edit command:
- Assign a value to a PID property, as follows:
fabric:profile-edit --pid PID/Key=Value ProfileName
fabric:profile-edit --pid PID/Key=Value ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Append a value to a delimited list (that is, where the property value is a comma-separated list), as follows:
fabric:profile-edit --append --pid PID/Key=ListItem ProfileName
fabric:profile-edit --append --pid PID/Key=ListItem ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Remove a value from a delimited list, as follows:
fabric:profile-edit --remove --pid PID/Key=ListItem ProfileName
fabric:profile-edit --remove --pid PID/Key=ListItem ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Delete a specific property key, as follows:
fabric:profile-edit --delete --pid PID/Key ProfileName
fabric:profile-edit --delete --pid PID/Key ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Delete a complete PID, as follows:
fabric:profile-edit --delete --pid PID ProfileName
fabric:profile-edit --delete --pid PID ProfileNameCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example of editing a PID inline Copy linkLink copied to clipboard!
io.fabric8.agent PID, changing the Maven repository list setting. The default profile contains a section like this:
io.fabric8.agent PID. So, by modifying the io.fabric8.agent PID, we effectively change the agent properties. You can modify the list of Maven repositories in the agent properties PID as follows:
fabric:profile-edit --pid io.fabric8.agent/org.ops4j.pax.url.mvn.repositories=http://repositorymanager.mylocalnetwork.net default
fabric:profile-edit --pid io.fabric8.agent/org.ops4j.pax.url.mvn.repositories=http://repositorymanager.mylocalnetwork.net default
fabric:profile-display on the default profile, you should see agent properties similar to the following:
Agent Properties :
org.ops4j.pax.url.mvn.repositories = http://repositorymanager.mylocalnetwork.net
Agent Properties :
org.ops4j.pax.url.mvn.repositories = http://repositorymanager.mylocalnetwork.net
Setting encrypted PID property values Copy linkLink copied to clipboard!
- Use the
fabric:encrypt-messagecommand to encrypt the property value, as follows:fabric:encrypt-message PropValue
fabric:encrypt-message PropValueCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command returns the encrypted property value,EncryptedValue.NoteThe default encryption algorithm used by Fabric isPBEWithMD5AndDES. - You can now set the property to the encrypted value,
EncryptedValue, using the following syntax:my.sensitive.property = ${crypt:EncryptedValue}my.sensitive.property = ${crypt:EncryptedValue}Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, using thefabric:profile-editcommand, you can set an encrypted value as follows:fabric:profile-edit --pid com.example.my.pid/my.sensitive.property=${crypt:EncryptedValue} Profilefabric:profile-edit --pid com.example.my.pid/my.sensitive.property=${crypt:EncryptedValue} ProfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Alternative method for encrypting PID property values Copy linkLink copied to clipboard!
- Use the Jasypt
encryptcommand-line tool to encrypt the property value, as follows:./encrypt.sh input="Property value to be encrypted" password=ZooPass verbose=false
./encrypt.sh input="Property value to be encrypted" password=ZooPass verbose=falseCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command returns the encrypted property value,EncryptedValue.NoteThe default encryption algorithm used by Fabric isPBEWithMD5AndDES. You must ensure that theencrypt.shutility is using the same algorithm as Fabric.
Customizing the PID property encryption mechanism Copy linkLink copied to clipboard!
- Customize the master password for encryption—using the following console command:
fabric:crypt-password-set MasterPassword
fabric:crypt-password-set MasterPasswordCopy to Clipboard Copied! Toggle word wrap Toggle overflow You can retrieve the current master password by entering thefabric:crypt-password-getcommand. The default value is the ensemble password (as returned byfabric:ensemble-password). - Customize the encryption algorithm—using the following console command:
fabric:crypt-algorithm-set Algorithm
fabric:crypt-algorithm-set AlgorithmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Where the encryption algorithm must be one of the algorithms supported by the underlying Jasypt encryption toolkit. You can retrieve the current encryption algorithm by entering thefabric:crypt-algorithm-getcommand. The default isPBEWithMD5AndDES.
Profile editor Copy linkLink copied to clipboard!
fabric:profile-edit command without any options, as follows:
fabric:profile-edit Profile [Version]
fabric:profile-edit Profile [Version]
Editing resources with the profile editor Copy linkLink copied to clipboard!
broker.xml file in the mq-amq profile, enter the following console command:
fabric:profile-edit --resource broker.xml mq-amq
fabric:profile-edit --resource broker.xml mq-amq
5.3. Profile Versions Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
fabric-agent, will choose the defined version and retrieve all the information provided by the specific version of the profile.
Creating a new version Copy linkLink copied to clipboard!
fabric:version-create command (analogous to creating a new branch in the underlying Git repository). The default version is 1.0. To create version 1.1, enter the following command:
fabric:version-create 1.1
fabric:version-create 1.1
feature-camel profile:
fabric:profile-display --version 1.1 feature-camel
fabric:profile-display --version 1.1 feature-camel
fabric:profile-edit command, specifying the version right after the profile argument. For example, to add the camel-jclouds feature to version 1.1 of the feature-camel profile, enter the following command:
fabric:profile-edit --features camel-jclouds feature-camel 1.1
fabric:profile-edit --features camel-jclouds feature-camel 1.1
Rolling upgrades and rollbacks Copy linkLink copied to clipboard!
mycontainer container to the 1.1 version, invoke the fabric:container-upgrade command as follows:
fabric:container-upgrade 1.1 mycontainer
fabric:container-upgrade 1.1 mycontainer
mycontainer to use version 1.1 of all the profiles currently assigned to it.
fabric:container-rollback command, as follows:
fabric:container-rollback 1.0 mycontainer
fabric:container-rollback 1.0 mycontainer
--all option, as follows:
fabric:container-upgrade --all 1.1 mycontainer
fabric:container-upgrade --all 1.1 mycontainer
Chapter 6. Fabric8 Maven Plug-In Copy linkLink copied to clipboard!
Abstract
6.1. Preparing to Use the Plug-In Copy linkLink copied to clipboard!
Edit your Maven settings Copy linkLink copied to clipboard!
~/.m2/settings.xml file to add the fabric server's user and password so that the maven plugin can log in to the fabric. For example, you could add the following server element to your settings.xml file:
Username and Password are the credentials of a Fabric user with administrative privileges (for example, the credentials you would use to log on to the Management Console).
Customising the repository ID Copy linkLink copied to clipboard!
fabric8.upload.repo. You can specify additional server elements in your settings.xml file for each of the fabrics you need to work with. To select the relevant credentials, you can set the serverId property in the Fabric8 Maven plug-in configuration section (see Section 6.4, “Configuration Properties”) or set the fabric8.serverId Maven property.
6.2. Using the Plug-In to Deploy a Maven Project Copy linkLink copied to clipboard!
Prerequisites Copy linkLink copied to clipboard!
- Your Maven
~/.m2/settings.xmlfile is configured as described in Section 6.1, “Preparing to Use the Plug-In”. - A JBoss Fuse container instance is running on your local machine (alternatively, if the container instance is running on a remote host, you must configure the plug-in's
jolokiaUrlproperty appropriately).
Running the plug-in on any Maven project Copy linkLink copied to clipboard!
mvn io.fabric8:fabric8-maven-plugin:1.0.0.redhat-355:deploy
mvn io.fabric8:fabric8-maven-plugin:1.0.0.redhat-355:deploy
Adding the plug-in to a Maven POM Copy linkLink copied to clipboard!
pom.xml file as follows:
mvn fabric8:deploy
mvn fabric8:deploy
What does the plug-in do? Copy linkLink copied to clipboard!
- Uploads any artifacts into the fabric's Maven repository,
- Lazily creates the Fabric profile or version you specify,
- Adds/updates the Maven project artifact into the profile configuration,
- Adds any additional parent profile, bundles or features to the profile.
Example Copy linkLink copied to clipboard!
quickstart examples, as follows:
cd InstallDir/quickstarts/rest mvn io.fabric8:fabric8-maven-plugin:1.0.0.redhat-355:deploy
cd InstallDir/quickstarts/rest
mvn io.fabric8:fabric8-maven-plugin:1.0.0.redhat-355:deploy
6.3. Configuring the Plug-In Copy linkLink copied to clipboard!
Specifying profile information Copy linkLink copied to clipboard!
configuration element to the plug-in configuration in your pom.xml file, as follows:
Multi-module Maven projects Copy linkLink copied to clipboard!
pom.xml file, as follows:
foo/pom.xml file you need only define the fabric8.profile property, as follows:
foo folder, such as foo/a and foo/b, will deploy to the same profile (in this case the profile, my-foo). You can use the same approach to put all of the projects under the bar folder into a different profile too.
fabric8.profile property to specify exactly where it gets deployed; along with any other property on the plug-in (see the Property Reference below).
Specifying features, additional bundles, repositories and parent profiles Copy linkLink copied to clipboard!
features element allows you to specify a space-separated list of features to include in the profile.
Configuring with Maven properties Copy linkLink copied to clipboard!
fabric8.. For example, to deploy a Maven project to the cheese profile name, enter the command:
mvn fabric8:deploy -Dfabric8.profile=cheese -Dfabric8.version=1.1
mvn fabric8:deploy -Dfabric8.profile=cheese -Dfabric8.version=1.1
fabric8.upload=false—for example:
mvn fabric8:deploy -Dfabric8.upload=false
mvn fabric8:deploy -Dfabric8.upload=false
Specifying profile resources Copy linkLink copied to clipboard!
src/main/fabric8, in your Maven project and add any resource files or a ReadMe.md file to your project, they will automatically be uploaded into the profile as well. For example, if you run the following commands from your Maven project directory:
mkdir -p src/main/fabric8 echo "## Hello World" >> src/main/fabric8/ReadMe.md mvn fabric8:deploy
mkdir -p src/main/fabric8
echo "## Hello World" >> src/main/fabric8/ReadMe.md
mvn fabric8:deploy
ReadMe.md wiki page.
6.4. Configuration Properties Copy linkLink copied to clipboard!
Specifying properties Copy linkLink copied to clipboard!
configuration element of the plug-in in your project's pom.xml file. For example, the profile property can be set as follows:
fabric8.. For example, to set the profile name, you could add the following property to your pom.xml file:
mvn fabric8:deploy -Dfabric8.profile=my-foo
mvn fabric8:deploy -Dfabric8.profile=my-foo
Property reference Copy linkLink copied to clipboard!
configuration element in the pom.xml file or as Maven properties, when prefixed by fabric8.):
| Parameter | Description |
|---|---|
profile
|
The name of the Fabric profile to deploy your project to. Defaults to the groupId-artifactId of your Maven project.
|
serverId
|
The server ID used to lookup in ~/.m2/settings/xml for the server element to find the username and password to log in to the fabric. Defaults to fabric8.upload.repo.
|
jolokiaUrl
|
The Jolokia URL of the JBoss Fuse Management Console. Defaults to http://localhost:8181/jolokia.
|
version
|
The Fabric version in which to update the profile. Defaults to the current version of the fabric. |
baseVersion
|
If the version does not exist, the baseVersion provides the initial values for the newly created version. This is like creating a branch from the baseVersion for a new version branch in git.
|
parentProfiles
|
Space-separated list of parent profile IDs to be added to the newly created profile. Defaults to karaf.
|
features
|
Space-separated list of features to add to the profile. For example, the following setting would include both the camel feature and the cxf feature: <features>camel cxf</features>
|
featureRepos
|
Space-separated list of feature repository URLs to add to the profile. The URL has the general form mvn:groupId/artifactId/version/xml/features.
|
bundles
|
Space-separated list of additional bundle URLs (of the form mvn:groupId/artifactId/version) to add to the newly created profile. Note you do not have to include the current Maven project artifact; this configuration is intended as a way to list dependent required bundles.
|
upload
|
Whether or not the deploy goal should upload the local builds to the fabric's Maven repository. You can disable this step if you have configured your fabric's Maven repository to reuse your local maven repository. Defaults to true.
|
profileConfigDir
|
The folder in your maven project containing resource files to be deployed into the profile, along with the artifact configuration. Defaults to src/main/fabric8. You should create the directory and add any configuration files or documentation you wish to add to your profile.
|
Chapter 7. ActiveMQ Brokers and Clusters Copy linkLink copied to clipboard!
Abstract
fabric:mq-create command to create and deploy clusters of brokers.
7.1. Creating a Standalone Broker Instance Copy linkLink copied to clipboard!
MQ profiles Copy linkLink copied to clipboard!
mq-base- An abstract profile, which defines some important properties and resources for the broker, but should never be used directly to instantiate a broker.
mq-default- A basic standalone broker, which inherits most of its properties from the
mq-baseprofile.
fabric:profile-display command, as follows:
JBossFuse:karaf@root> fabric:profile-display mq-default ... JBossFuse:karaf@root> fabric:profile-display mq-base ...
JBossFuse:karaf@root> fabric:profile-display mq-default
...
JBossFuse:karaf@root> fabric:profile-display mq-base
...
Creating a new broker instance Copy linkLink copied to clipboard!
mq-default profile.
mq-default broker instance called broker1, enter the following console command:
JBossFuse:karaf@root>fabric:container-create-child --profile mq-default root broker1
The following containers have been created successfully:
broker1
JBossFuse:karaf@root>fabric:container-create-child --profile mq-default root broker1
The following containers have been created successfully:
broker1
broker1 with a broker of the same name running on it.
fabric:mq-create command Copy linkLink copied to clipboard!
fabric:mq-create command provides a short cut to creating a broker, but with more flexibility, because it also creates a new profile. To create a new broker instance called brokerx using 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
JBossFuse:karaf@root> fabric:mq-create --create-container broker --replicas 1 brokerx
MQ profile mq-broker-default.brokerx ready
fabric:container-create-child command, fabric:mq-create creates a container called broker1 and 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 themq-baseprofile template, - It is possible to edit the
mq-broker-default.brokerxprofile, to customize the configuration of this new broker. - The
--replicasoption lets you specify the number of master/slave broker replicas (for more details, see Section 7.3.2, “Master-Slave Cluster”). In this example, we specify one replica (the default is two).
mq-broker-Group.BrokerName by default. If you want the profile to have the same name as the broker (which was the default in JBoss A-MQ version 6.0), you can specify the profile name explicitly using the --profile option.
Starting a broker on an existing container Copy linkLink copied to clipboard!
fabric:mq-create command can be used to deploy brokers on existing containers. Consider the following example, which creates a new Fuse MQ broker in two steps:
mq-broker-default.brokerx profile to the container, by invoking fabric:mq-create with the --assign-container option. Of course, instead of deploying to a local child container (as in this example), we could assign the broker to an SSH container or a cloud container.
Broker groups Copy linkLink copied to clipboard!
fabric:mq-create command 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 default group by default.
--group option of the fabric:mq-create command. For example, to create a new broker that registers with the west-coast group, enter the following console command:
JBossFuse:karaf@root> fabric:mq-create --create-container broker --replicas 1 --group west-coast brokery MQ profile mq-broker-default.brokery ready
JBossFuse:karaf@root> fabric:mq-create --create-container broker --replicas 1 --group west-coast brokery
MQ profile mq-broker-default.brokery ready
west-coast group 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 7.3, “Topologies”.
7.2. Connecting to a Broker Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
default group.
Client URL Copy linkLink copied to clipboard!
discovery:(fabric:GroupName)
discovery:(fabric:GroupName)
default group, the client would use the following URL:
discovery:(fabric:default)
discovery:(fabric:default)
Example client profiles Copy linkLink copied to clipboard!
example-mq profile into a container. The example-mq profile instantiates a pair of messaging clients: a producer client, that sends messages continuously to the FABRIC.DEMO queue on the broker; and a consumer client, that consumes messages from the FABRIC.DEMO queue.
example-mq profile, by entering the following command:
JBossFuse:karaf@root> fabric:container-create-child --profile example-mq root example
JBossFuse:karaf@root> fabric:container-create-child --profile example-mq root example
example container is successfully provisioned, using the following console command:
JBossFuse:karaf@root> watch container-list
JBossFuse:karaf@root> watch container-list
JBossFuse:karaf@root> container-connect example JBossFuse:karaf@example> log:display
JBossFuse:karaf@root> container-connect example
JBossFuse:karaf@example> log:display
7.3. Topologies Copy linkLink copied to clipboard!
7.3.1. Load-Balancing Cluster Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
loadbal, and with three brokers registered in the group: brokerx, brokery, and brokerz. This type of topology is ideal for load balancing non-persistent messages across brokers and for providing high-availability.
Figure 7.1. Load-Balancing Cluster
Create brokers in a load-balancing cluster Copy linkLink copied to clipboard!
- Choose a group name for the load-balancing cluster.
- Each broker in the cluster registers with the chosen group.
- Each broker must be identified by a unique broker name.
- Normally, each broker is deployed in a separate container.
loadbal and the cluster consists of three broker instances with broker names: brokerx, brokery, and brokerz.
- First of all create some containers:
JBossFuse:karaf@root> container-create-child root broker 3 The following containers have been created successfully: Container: broker1. Container: broker2. Container: broker3.
JBossFuse:karaf@root> container-create-child root broker 3 The following containers have been created successfully: Container: broker1. Container: broker2. Container: broker3.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Wait until the containers are successfully provisioned. You can conveniently monitor them using the
watchcommand, as follows:JBossFuse:karaf@root> watch container-list
JBossFuse:karaf@root> watch container-listCopy to Clipboard Copied! Toggle word wrap Toggle overflow - You can then assign broker profiles to each of the containers, using the
fabric:mq-createcommand, as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - You can use the
fabric:profile-listcommand to see the new profiles created for these brokers:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - You can use the
fabric:cluster-listcommand to view the cluster configuration for this load balancing cluster:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Configure clients of a load-balancing cluster Copy linkLink copied to clipboard!
discovery:(fabric:GroupName), which automatically load balances the client across the available brokers in the cluster. For example, to connect a client to the loadbal cluster, you would use a URL like the following:
discovery:(fabric:loadbal)
discovery:(fabric:loadbal)
mq-create command automatically generates a profile named mq-client-GroupName, which you can combine either with the example-mq-consumer profile or with the example-mq-producer profile to create a client of the load-balancing cluster.
loadbal group, you can deploy the mq-client-loadbal profile and the example-mq-consumer profile together in a child container, by entering the following command:
JBossFuse:karaf@root> container-create-child --profile mq-client-loadbal --profile example-mq-consumer root consumer The following containers have been created successfully: Container: consumer.
JBossFuse:karaf@root> container-create-child --profile mq-client-loadbal --profile example-mq-consumer root consumer
The following containers have been created successfully:
Container: consumer.
loadbal group, you can deploy the mq-client-loadbal profile and the example-mq-producer profile together in a child container, by entering the following command:
JBossFuse:karaf@root> container-create-child --profile mq-client-loadbal --profile example-mq-producer root producer The following containers have been created successfully: Container: producer.
JBossFuse:karaf@root> container-create-child --profile mq-client-loadbal --profile example-mq-producer root producer
The following containers have been created successfully:
Container: producer.
JBossFuse:karaf@root> container-connect consumer JBossFuse:admin@consumer> log:display 2014-01-16 14:31:41,776 | INFO | Thread-42 | ConsumerThread | org.fusesource.mq.ConsumerThread 54 | 110 - org.jboss.amq.mq-client - 6.1.0.redhat-312 | Received test message: 982 2014-01-16 14:31:41,777 | INFO | Thread-42 | ConsumerThread | org.fusesource.mq.ConsumerThread 54 | 110 - org.jboss.amq.mq-client - 6.1.0.redhat-312 | Received test message: 983
JBossFuse:karaf@root> container-connect consumer
JBossFuse:admin@consumer> log:display
2014-01-16 14:31:41,776 | INFO | Thread-42 | ConsumerThread | org.fusesource.mq.ConsumerThread 54 | 110 - org.jboss.amq.mq-client - 6.1.0.redhat-312 | Received test message: 982
2014-01-16 14:31:41,777 | INFO | Thread-42 | ConsumerThread | org.fusesource.mq.ConsumerThread 54 | 110 - org.jboss.amq.mq-client - 6.1.0.redhat-312 | Received test message: 983
7.3.2. Master-Slave Cluster Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
masterslave, and three brokers that compete with each other to register as the broker, hq-broker. A broker becomes the master by acquiring a lock (where the lock implementation is provided by the underlying ZooKeeper registry). The other two brokers that fail to acquire the lock remain as slaves (but they continue trying to acquire the lock, at regular time intervals).
Figure 7.2. Master-Slave Cluster
Create brokers in a master-slave cluster Copy linkLink copied to clipboard!
- Choose a group name for the master-slave cluster.
- Each broker in the cluster registers with the chosen group.
- Each broker must be identified by the same virtual broker name.
- Normally, each broker is deployed in a separate container.
masterslave and the cluster consists of three broker instances, each with the same broker name: hq-broker. You can create this cluster by entering a single fabric:mq-create command, as follows:
JBossFuse:karaf@root> mq-create --create-container broker --replicas 3 --group masterslave hq-broker
JBossFuse:karaf@root> mq-create --create-container broker --replicas 3 --group masterslave hq-broker
broker1, broker2 and broker3 (possibly running on separate machines), you can deploy a cluster of three brokers to the containers by entering the following command:
JBossFuse:karaf@root> mq-create --assign-container broker1,broker2,broker3 --group masterslave hq-broker
JBossFuse:karaf@root> mq-create --assign-container broker1,broker2,broker3 --group masterslave hq-broker
Configure clients of a master-slave cluster Copy linkLink copied to clipboard!
discovery:(fabric:GroupName), which automatically connects the client to the current master server. For example, to connect a client to the masterslave cluster, you would use a URL like the following:
discovery:(fabric:masterslave)
discovery:(fabric:masterslave)
mq-client-masterslave, to create sample clients. For example, to create an example consumer client in its own container, enter the following console command:
JBossFuse:karaf@root> container-create-child --profile mq-client-masterslave --profile example-mq-consumer root consumer The following containers have been created successfully: Container: consumer.
JBossFuse:karaf@root> container-create-child --profile mq-client-masterslave --profile example-mq-consumer root consumer
The following containers have been created successfully:
Container: consumer.
JBossFuse:karaf@root> container-create-child --profile mq-client-masterslave --profile example-mq-producer root producer The following containers have been created successfully: Container: producer.
JBossFuse:karaf@root> container-create-child --profile mq-client-masterslave --profile example-mq-producer root producer
The following containers have been created successfully:
Container: producer.
Locking mechanism Copy linkLink copied to clipboard!
Re-using containers for multiple clusters Copy linkLink copied to clipboard!
broker1, broker2, and broker3, already running the hq-broker cluster, it is possible to reuse the same containers for another highly available broker cluster, web-broker. You can assign the web-broker profile to the existing containers with the following command:
mq-create --assign-container broker1,broker2,broker3 web-broker
mq-create --assign-container broker1,broker2,broker3 web-broker
web-broker profile to the same containers already running hq-broker. Fabric automatically prevents two masters from running on the same container, so the master for hq-broker will run on a different container from the master for web-broker. This arrangement makes optimal use of the available resources.
Configuring persistent data Copy linkLink copied to clipboard!
fabric:mq-create command enables you to specify the location of the data directory, as follows:
mq-create --assign-container broker1 --data /var/activemq/hq-broker hq-broker
mq-create --assign-container broker1 --data /var/activemq/hq-broker hq-broker
hq-broker virtual broker, which uses the /var/activemq/hq-broker directory for the data (and store) location. You can then mount some shared storage to this path and share the storage amongst the brokers in the master-slave cluster.
7.3.3. Broker Networks Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Broker networks Copy linkLink copied to clipboard!
Creating network connectors Copy linkLink copied to clipboard!
--networks option to the fabric:mq-create command.
Example broker network Copy linkLink copied to clipboard!
Figure 7.3. Broker Network with Master-Slave Clusters
- The first cluster has the group name,
us-west, and provides high-availability with a master-slave cluster of two brokers,us-west1andus-west2. - The second cluster has the group name,
us-east, and provides high-availability with a master-slave cluster of two brokers,us-east1andus-east2.
us-east group (consisting of the two containers us-east1 and us-east2), you would log on to a root container running in the US East location and enter a command like the following:
mq-create --group us-east --networks us-west --networks-username User --networks-password Pass --create-container us-east us-east
mq-create --group us-east --networks us-west --networks-username User --networks-password Pass --create-container us-east us-east
--networks option specifies the name of the broker group you want to connect to, and the User and Pass are the credentials required to log on to the us-west broker cluster. By default, the fabric:mq-create command creates a master/slave pair of brokers.
us-west group (consisting of the two containers us-west1 and us-west2), you would log on to a root container running in the US West location and enter a command like the following:
mq-create --group us-west --networks us-east --networks-username User --networks-password Pass --create-container us-west us-west
mq-create --group us-west --networks us-east --networks-username User --networks-password Pass --create-container us-west us-west
User and Pass are the credentials required to log on to the us-east broker cluster.
--assign-container option in place of --create-container.
Connecting to the example broker network Copy linkLink copied to clipboard!
discovery:(fabric:us-east)
discovery:(fabric:us-east)
discovery:(fabric:us-west)
discovery:(fabric:us-west)
7.4. Broker Configuration Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Setting OSGi Config Admin properties Copy linkLink copied to clipboard!
broker1 profile created by entering the following fabric:mq-create command:
fabric:mq-create --create-container broker --replicas 1 --networks us-west brokerx
fabric:mq-create --create-container broker --replicas 1 --networks us-west brokerx
mq-broker-default.brokerx, and assigns this profile to the newly created broker1 container.
mq-broker-Group.BrokerName by default. If you want the profile to have the same name as the broker (which was the default in JBoss A-MQ version 6.0), you can specify the profile name explicitly using the --profile option.
mq-broker-default.brokerx profile using the fabric:profile-display command, as follows:
org.fusesource.mq.fabric.server-brokerx PID are a variety of property settings, such as network and group. You can now add more properties to this PID to customize the broker configuration.
Setting network connector properties Copy linkLink copied to clipboard!
network.NetworkPropName. For example, to add the setting, network.bridgeTempDestinations=false, to the PID for brokerx, enter the following console command:
profile-edit --pid org.fusesource.mq.fabric.server-brokerx/network.bridgeTempDestinations=false brokerx
profile-edit --pid org.fusesource.mq.fabric.server-brokerx/network.bridgeTempDestinations=false brokerx
Network connector properties by reflection Copy linkLink copied to clipboard!
network.OptionName can be used to set the corresponding OptionName property on the org.apache.activemq.network.NetworkBridgeConfiguration class. In particular, this implies you can set any of the following network.OptionName properties:
| Property | Default | Description |
|---|---|---|
name | bridge | Name of the network - for more than one network connector between the same two brokers, use different names |
userName | None | Username for logging on to the remote broker port, if authentication is enabled. |
password | None | Password for logging on to the remote broker port, if authentication is enabled. |
dynamicOnly | false | If true, only activate a networked durable subscription when a corresponding durable subscription reactivates, by default they are activated on start-up. |
dispatchAsync | true | Determines how the network bridge sends messages to the local broker. If true, the network bridge sends messages asynchronously. |
decreaseNetworkConsumerPriority | false | If true, starting at priority -5, decrease the priority for dispatching to a network Queue consumer the further away it is (in network hops) from the producer. If false, all network consumers use same default priority (that is, 0) as local consumers. |
consumerPriorityBase | -5 | Sets the starting priority for consumers. This base value will be decremented by the length of the broker path when decreaseNetworkConsumerPriority is set. |
networkTTL | 1 | The number of brokers in the network that messages and subscriptions can pass through (sets both messageTTL and consumerTTL) |
messageTTL | 1 | The number of brokers in the network that messages can pass through. |
consumerTTL | 1 | The number of brokers in the network that subscriptions can pass through (keep to 1 in a mesh). |
conduitSubscriptions | true | Multiple consumers subscribing to the same destination are treated as one consumer by the network. |
duplex | false | If true, a network connection is used both to produce and to consume messages. This is useful for hub and spoke scenarios, when the hub is behind a firewall, and so on. |
prefetchSize | 1000 | Sets the prefetch size on the network connector's consumer. It must be greater than 0, because network consumers do not poll for messages |
suppressDuplicateQueueSubscriptions | false | If true, duplicate subscriptions in the network that arise from network intermediaries are suppressed. For example, consider brokers A, B, and C, networked using multicast discovery. A consumer on A gives rise to a networked consumer on B and C. In addition, C networks to B (based on the network consumer from A) and B networks to C. When true, the network bridges between C and B (being duplicates of their existing network subscriptions to A) will be suppressed. Reducing the routing choices in this way provides determinism when producers or consumers migrate across the network as the potential for dead routes (stuck messages) are eliminated. The networkTTL value needs to match or exceed the broker count to require this intervention. |
suppressDuplicateTopicSubscriptions | true | If true, duplicate network topic subscriptions (in a cyclic network) are suppressed. |
bridgeTempDestinations | true |
Whether to broadcast advisory messages for temporary destinations created in the network of brokers. Temporary destinations are typically created for request-reply messages. Broadcasting the information about temp destinations is turned on by default, so that consumers of a request-reply message can be connected to another broker in the network and still send back the reply on the temporary destination specified in the
JMSReplyTo header. In an application scenario where most or all of the messages use the request-reply pattern, this generates additional traffic on the broker network, because every message typically sets a unique JMSReplyTo address (which causes a new temp destination to be created and broadcasted with an advisory message in the network of brokers).
If you disable this feature, this network traffic can be reduced, but in this case the producers and consumers of a request-reply message need to be connected to the same broker. Remote consumers (that is, connected through another broker in your network) will not be able to send the reply message, but instead will raise a
temp destination does not exist exception.
|
alwaysSyncSend | false | If true, non-persistent messages are sent to the remote broker using request/reply semantics instead of oneway message semantics. This setting affects both persistent and non-persistent messages the same way. |
staticBridge | false | If true, the broker does not respond dynamically to new consumers. It uses only staticallyIncludedDestinations to create demand subscriptions. |
useCompression | false | Compresses the message body when sending it over the network. |
advisoryForFailedForward | false | If true, send an advisory message when the broker fails to forward the message to the temporary destination across the bridge. |
useBrokerNamesAsIdSeed | true | Add the broker name as a prefix to connections and consumers created by the network bridge. It helps with visibility. |
gcDestinationViews | true | If true, remove any MBeans for destinations that have not been used for a while. |
gcSweepTime | 60000 | The period of inactivity in milliseconds, after which we remove MBeans. |
checkDuplicateMessagesOnDuplex | false | If true, check for duplicates on the duplex connection. |
Broker configuration file Copy linkLink copied to clipboard!
mq-base profile. That is, in the ZooKeeper registry, the broker.xml file is stored in the following location:
/fabric/configs/versions/1.0/profiles/mq-base/broker.xml
/fabric/configs/versions/1.0/profiles/mq-base/broker.xml
broker-name and data) and it's important that you reuse them properly. The easiest way to edit this configuration is to use the Fuse Management Console (see "Management Console User Guide") or the built-in profile text editor (see Appendix A, Editing Profiles with the Built-In Text Editor).
Additional broker configuration files Copy linkLink copied to clipboard!
mq-base profile, for example:
/fabric/configs/versions/1.0/profiles/mq-base/mybroker.xml
/fabric/configs/versions/1.0/profiles/mq-base/mybroker.xml
mybroker.xml configuration by invoking the fabric:mq-create command with the --config option, as follows:
fabric:mq-create --config mybroker.xml brokerx
fabric:mq-create --config mybroker.xml brokerx
--config option assumes that the configuration file is stored in the current version of the mq-base profile, so you need to specify only the file name (that is, the full ZooKeeper path is not required).
Part II. Fabric in Production Copy linkLink copied to clipboard!
Abstract
Chapter 8. Fabric Ensemble and Registry Copy linkLink copied to clipboard!
Abstract
8.1. Fabric Registry Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Registry structure Copy linkLink copied to clipboard!
Parts of the registry Copy linkLink copied to clipboard!
- Configuration Registry—the logical configuration of your fabric, which typically contains no physical machine information. It contains details of the applications to be deployed and their dependencies.
- Runtime Registry—contains details of how many machines are actually running, their physical location, and what services they are implementing.
Making the registry highly available Copy linkLink copied to clipboard!
8.2. Administering a Fabric Ensemble Copy linkLink copied to clipboard!
Recommendations for an ensemble in production Copy linkLink copied to clipboard!
- Deploy a minimum of five Fabric servers in production (if one server is taken down for maintenance, one other server can fail, and the Fabric registry will still be available).
- Fabric servers should be deployed on separate host machines.
- Each Fabric server should only have a Fabric registry agent deployed inside it. No other profiles should be deployed in it.
- The size of the ensemble should be fixed at the outset, and not changed later (if you subsequently add or remove containers from the ensemble, the ZooKeeper IP ports would be re-assigned).
Creating an ensemble Copy linkLink copied to clipboard!
- Create an initial ensemble, consisting of one Fabric server.
- Expand the ensemble, by adding an even number of containers.
Creating an initial ensemble Copy linkLink copied to clipboard!
fabric:create console command (which converts the current container into a Fabric server, which is a sole member of the newly created ensemble). Alternatively, when creating a new container with the fabric:container-create-ssh or fabric:container-create-cloud commands, you can pass the --ensemble-server option.
fabric:create command, see Chapter 3, Creating a New Fabric.
Expanding the ensemble Copy linkLink copied to clipboard!
fabric:ensemble-add command. To expand the ensemble, perform the following steps:
- Create some new managed containers in the current fabric, which you can then add to the ensemble. Use the default profile for these new containers. For a production environment, it is recommended that you create at least four new managed containers (must be an even number), each running on their own host.
- While logged on to a container in the fabric, use the
fabric:ensemble-addcommand to add the managed containers to the ensemble. For example, given the four managed containers,container1,container2,container3, andcontainer4, you would enter the following command:fabric:ensemble-add container1 container2 container3 container4
fabric:ensemble-add container1 container2 container3 container4Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteBecause the total number of containers in an ensemble must always be odd, you must specify an even number of containers to thefabric:ensemble-addcommand. - To check that the ensemble has been successfully created, invoke the
fabric:container-listcommand.
Taking a Fabric server down for maintenance Copy linkLink copied to clipboard!
fabric:container-stop command, specifying the name of the Fabric server.
Chapter 9. Fabric Agents Copy linkLink copied to clipboard!
Abstract
9.1. Introduction Copy linkLink copied to clipboard!
Fabric agent Copy linkLink copied to clipboard!
- Retrieves the profiles and versions assigned to the container on which it is running.
- Reconfigures the container.
- Calculates what needs to be installed, removed or updated on the container.
- Performs the requisite install, remove, and update actions.
Agent modules Copy linkLink copied to clipboard!
- [fabric-configadmin]
- The Fabric configuration admin bridge. Translates the registry information into configuration information.
- [fabric-agent]
- The deployment agent. Reads the translated configuration and provisions the container accordingly.
9.2. The Configuration Admin Bridge Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Information in a profile Copy linkLink copied to clipboard!
- Configuration information—which includes:
- System configuration
- OSGi configuration
- Provisioning information—which includes lists of:
- Bundles
- Karaf features
- FABs
Actions performed Copy linkLink copied to clipboard!
io.fabric8.agent PID (in the context of the OSGi Configuration Admin service, a PID is a named collection of property settings).
io.fabric8.agent PID, even when there are multiple assigned profiles.
io.fabric8.agent PID.
Configuration updates Copy linkLink copied to clipboard!
9.3. The Deployment Agent Copy linkLink copied to clipboard!
Actions performed Copy linkLink copied to clipboard!
io.fabric8.agent PID. Any change in that configuration will trigger the deployment agent.
- The deployment agent reads the whole
io.fabric8.agentPID and calculates what bundles are to be installed in the container. - If the profiles assigned to the container specify any Karaf features or FABs, the deployment agent translates them into a list of bundles, so that the agent obtains a complete list of bundles to install.
- The deployment agent compares the list of bundles to install with the list of bundles currently installed, in order to identify:
- Bundles to uninstall,
- Bundles to install,
- Bundles to update.
- The deployment agent then performs the bundle uninstalling, installing, and updating in the container.
Downloading artifacts Copy linkLink copied to clipboard!
- Registered Fabric Maven proxies
- Configured Maven repositories (any Maven repository configured in the profile overlay).
org.ops4j.pax.url.mvn.repositories property of the io.fabric8.agent PID.
org.ops4j.pax.url.mvn.repositories property using the fabric:profile-edit command:
fabric:profile-edit --pid io.fabric8.agent/org.ops4j.pax.url.mvn.repositories=http://repositorymanager.mylocalnetwork.net default
fabric:profile-edit --pid io.fabric8.agent/org.ops4j.pax.url.mvn.repositories=http://repositorymanager.mylocalnetwork.net default
default profile, which is the ancestor of all of the standard profiles, is the ideal place for this.
Container restarts Copy linkLink copied to clipboard!
- Changes to the OSGi framework;
- Changes to the OSGi framework configuration.
Monitoring the provisioning status Copy linkLink copied to clipboard!
fabric:container-list command.
fabric:container-list command as an argument to the shell:watch command, as follows:
shell:watch fabric:container-list
shell:watch fabric:container-list
Resolution and startup ordering Copy linkLink copied to clipboard!
Import-Package- For each package listed here, the OBR resolver searches for a bundle that declares the package in a corresponding
Export-Packageheader. Import-Service- For each service listed here, the OBR resolver searches for a bundle that declares the service in a corresponding
Export-Serviceheader.
Export-Service header to bundles that implement services. Blueprint configuration files with mandatory references to services will automatically be packaged with the Import-Service bundle header (assuming that you use the maven-bundle-plugin). If the bundle that exports the service does not explicitly specify an Export-Service header, resolution will fail. To fix this error, either the exporter bundle must add an Export-Service declaration, or the importer bundle must remove the Import-Service directive.
Chapter 10. Allocating Ports Copy linkLink copied to clipboard!
Abstract
10.1. The Port Service Copy linkLink copied to clipboard!
What is the port service? Copy linkLink copied to clipboard!
- Ports clashing with third-party services—a server machine in a production environment often has multiple services deployed on it, with a wide range of IP ports in use. In this environment, there is a relatively large risk that a Fabric container could clash with existing IP ports.
- Ports clashing with other Fabric containers—when multiple Fabric containers are deployed on the same host, it is necessary to configure their standard services with different IP ports. Setting the IP ports manually would be a considerable nuisance (and error prone).
- Ports clashing within a container—a port clash can also occur within a single container, if multiple services are competing for the same ports (for example, multiple routes binding to the same ports). Because Fabric containers are highly dynamic, we need to be able to prevent port clashes in this case, and ports must be allocated and de-allocated as services come and go.
Benefits of the port service Copy linkLink copied to clipboard!
- Avoiding port clashes for standard container services
- Avoiding port clashes for custom services
Avoiding port clashes for standard container services Copy linkLink copied to clipboard!
Avoiding port clashes for custom services Copy linkLink copied to clipboard!
Using the port service in your own applications Copy linkLink copied to clipboard!
- Use the OSGi Config Admin service to define a key, whose value is a port range. Use the following syntax to define a key:
KeyID = ${port:MinValue,MaxValue}KeyID = ${port:MinValue,MaxValue}Copy to Clipboard Copied! Toggle word wrap Toggle overflow The preceding syntax defines the key,KeyID, whereMinValuespecifies the minimum value of the IP port, andMaxValuespecifies the maximum value of the IP port. You can create this key using the standard Karaf commands for editing persistent IDs (PIDs) and their keys (using thefabric:profile-editcommand with the--pidoption in a Fabric container).For example, if you are logged into a Fabric container, you can see that thedefaultprofile defines the key,org.osgi.service.http.port, which specifies the container's Jetty port, as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - In your application's XML configuration (either Spring XML or Blueprint XML), replace the literal port value in the service's address by a property placeholder—for example,
${org.osgi.service.http.port}—which substitutes the value of the key defined in step 1.For a complete example of how to configure the property placeholder, see Section 10.2, “Using the Port Service”.
How the port service allocates a port Copy linkLink copied to clipboard!
${port:9090,9190}) running on a specific target host, when you start up the service for the first time, the port service allocates a port as follows:
- Determines which ports in the range are already in use on the target host (whether local or remote), by actually trying to bind to the ports.
- Checks the registered ports in the ZooKeeper registry for all of the containers deployed on the target host (even if the containers are currently not running).
- Allocates the first free port, within the specified range, that does not clash with any of the ports discovered in steps 1 and 2.
How allocated ports are stored Copy linkLink copied to clipboard!
/fabric/registry/ports/
/fabric/registry/ports/
KeyID, is filed under its corresponding persistent ID, PID, and container name, ContainerName, as follows:
/fabric/registry/ports/containers/ContainerName/PID/KeyID
/fabric/registry/ports/containers/ContainerName/PID/KeyID
Child1, the key for the child container's Jetty port would be stored in the following ZooKeeper node:
/fabric/registry/ports/containers/Child1/org.ops4j.pax.web/org.osgi.service.http.port
/fabric/registry/ports/containers/Child1/org.ops4j.pax.web/org.osgi.service.http.port
Keys used by the standard container services Copy linkLink copied to clipboard!
/fabric/registry/ports/containers/ContainerName/org.apache.karaf.shell/sshPort /fabric/registry/ports/containers/ContainerName/org.ops4j.pax.web/org.osgi.service.http.port /fabric/registry/ports/containers/ContainerName/org.apache.karaf.management/rmiServerPort /fabric/registry/ports/containers/ContainerName/org.apache.karaf.management/rmiRegistryPort
/fabric/registry/ports/containers/ContainerName/org.apache.karaf.shell/sshPort
/fabric/registry/ports/containers/ContainerName/org.ops4j.pax.web/org.osgi.service.http.port
/fabric/registry/ports/containers/ContainerName/org.apache.karaf.management/rmiServerPort
/fabric/registry/ports/containers/ContainerName/org.apache.karaf.management/rmiRegistryPort
Behavior upon stopping and restarting a container Copy linkLink copied to clipboard!
- The ports used by the container's services remain constant (after the initial allocation has occurred). You can advertise the ports to clients and be confident that the ports will remain valid over the long term.
- If, while the container is stopped, another service binds to one of the container's ports, there is a port clash when the container restarts, and the affected service fails to start (but at least we can guarantee that Fabric will not cause such a clash, because Fabric deliberately avoids re-using allocated container ports).
Deallocating ports Copy linkLink copied to clipboard!
fabric:container-delete command), Fabric deallocates all of the ports assigned to that container, so that they become available for use again by services in other containers. In other words, when the ContainerName container is deleted, all of the key entries under /fabric/registry/ports/containers/ContainerName are deleted from the ZooKeeper registry.
10.2. Using the Port Service Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
example-camel-cxf profile as an example. There are two basic steps to configuring the port service in your application:
- At development time—using the property placeholder service, replace a service's fixed port number by a key.
- At deployment time—using the OSGi Config Admin service, specify the key value as a port range. For example, you can specify the key value as a PID property setting in a Fabric profile.
Demonstration code Copy linkLink copied to clipboard!
example-camel-cxf profile. The source code for the example is taken from the fabric-camel-cxf example on Github, which is available from the following URL:
https://github.com/fabric8io/fabric8/tree/1.x/fabric/fabric-examples/fabric-camel-cxf
https://github.com/fabric8io/fabric8/tree/1.x/fabric/fabric-examples/fabric-camel-cxf
Property placeholder in XML configuration Copy linkLink copied to clipboard!
src/main/resources/OSGI-INF/blueprint/cxf.xml, in the fabric-camel-cxf demonstration):
cxf:cxfEndpoint element. In the address attribute, the port number is specified by substituting the greeterPort key, ${greeterPort}. The property placeholder mechanism is configured by the cm:property-placeholder element, which specifies that the greeterPort property belongs to the io.fabric8.examples.camel.cxf PID. The property placeholder mechanism is integrated with the OSGi Config Admin service, which allows you to override the port number at deployment time.
Specifying a port range using OSGi Config Admin Copy linkLink copied to clipboard!
example-camel-cxf profile, the port number is integrated with the port service and specified as a port range.
example-camel-cxf Fabric profile. You can see the configured port range by entering the following console command:
JBossFuse:karaf@root> fabric:profile-display example-camel-cxf
JBossFuse:karaf@root> fabric:profile-display example-camel-cxf
io.fabric8.examples.camel.cxf persistent ID:
greeterPort key is set to ${port:9090,9190}.
Modifying the port range Copy linkLink copied to clipboard!
example-camel-cxf profile, you can do so using the fabric:profile-edit console command. For example, to change the value of greeterPort to the range, ${port:7070,7170}, you would enter the following console command:
JBossFuse:karaf@root> fabric:profile-edit
--pid io.fabric8.examples.camel.cxf/greeterPort=\$\{port:7070,7170\}
example-camel-cxf
JBossFuse:karaf@root> fabric:profile-edit
--pid io.fabric8.examples.camel.cxf/greeterPort=\$\{port:7070,7170\}
example-camel-cxf
$ sign and the curly braces, { }, must be escaped by the backslash character, \, as shown. Alternatively, if you prefer to edit the port range using the built-in text editor, you can enter the following console command instead:
JBossFuse:karaf@root> fabric:profile-edit --pid io.fabric8.examples.camel.cxf example-camel-cxf
JBossFuse:karaf@root> fabric:profile-edit --pid io.fabric8.examples.camel.cxf example-camel-cxf
Chapter 11. Gateway Copy linkLink copied to clipboard!
Abstract
11.1. Gateway Architecture Copy linkLink copied to clipboard!
Deployment strategies Copy linkLink copied to clipboard!
- Run the gateway on each machine that needs to discover services and communicate with it through
localhost. In this case, you do not need to hard code any host names in your messaging or Web clients and the connection to the gateway onlocalhostis nice and fast. - Run the gateway on one or more known hosts using DNS or VIP load balancing (mapping host names to machines). In thise case, you can use a fixed host name for all your services
How the gateway works Copy linkLink copied to clipboard!
11.2. Running the Gateway Copy linkLink copied to clipboard!
Deploy a gateway profile Copy linkLink copied to clipboard!
gateway-mq- Profile for a messaging gateway (for accessing Apache ActiveMQ brokers in the fabric).
gateway-http- Profile for a HTTP gateway (for Web applications or Web services).
11.3. Configuring the Gateway Copy linkLink copied to clipboard!
Configuring with the Management Console Copy linkLink copied to clipboard!
HTTP mapping rules Copy linkLink copied to clipboard!
example-quickstarts-rest profile, that uses a URI like /cxf/crm/customerservice/customers/123 on whatever host and port it is deployed on. Hence, by default, it is visible on the gateway at http://localhost:9000/cxf/crm/customerservice/customers/123. For this example, the URI template is:
{contextPath}/
{contextPath}/
/cxf/crm) and append /, giving /cxf/crm/. Any request within that path is then passed to an instance of the CXF crm service.
Selecting part of the ZooKeeper registry Copy linkLink copied to clipboard!
| ZooKeeper Path | Description |
|---|---|
/fabric/registry/clusters/apis/rest
|
REST based web services |
/fabric/registry/clusters/apis/ws
|
SOAP based web services |
/fabric/registry/clusters/servlets
|
Servlets (registered usually individually via the OSGI APIs) |
/fabric/registry/clusters/webapps
|
Web Applications (i.e. WARs) |
Segregating URI paths Copy linkLink copied to clipboard!
/api/ and Web applications to be available under /app/, update the URI templates as follows:
ZooKeeperPath: /fabric/registry/clusters/apis
URI template: /api{contextPath}/
ZooKeeperPath: /fabric/registry/clusters/apis
URI template: /api{contextPath}/
ZooKeeperPath: /fabric/registry/clusters/webapps
URI template: /app{contextPath}/
ZooKeeperPath: /fabric/registry/clusters/webapps
URI template: /app{contextPath}/
ZooKeeperPath: /fabric/registry/clusters/apis/rest
URI template: /rest{contextPath}/
ZooKeeperPath: /fabric/registry/clusters/apis/ws
URI template: /ws{contextPath}/
ZooKeeperPath: /fabric/registry/clusters/apis/rest
URI template: /rest{contextPath}/
ZooKeeperPath: /fabric/registry/clusters/apis/ws
URI template: /ws{contextPath}/
11.4. Versioning Copy linkLink copied to clipboard!
Explicit URIs Copy linkLink copied to clipboard!
/version/{version}{contextPath}/
/version/{version}{contextPath}/
1.0 and 1.1 versions of a profile that packages Web services or Web applications, you can now access the different versions using version-specific URIs. For example, if you are running version 1.0 and version 1.1 implementations of the example-quickstarts-rest profile, you can access either one through the following URIs:
- Version 1.0 through http://localhost:9000/version/1.0/cxf/crm/customerservice/customers/123
- Version 1.1 through http://localhost:9000/version/1.1/cxf/crm/customerservice/customers/123
Rolling upgrades Copy linkLink copied to clipboard!
1.0 version of the gateway-http profile and run a few services, you will see all 1.0 versions of them. If you run some 1.1 versions of these services, the gateway will not see them. If you now do a rolling upgrade of your gateway to version 1.1, it will switch to showing only the 1.1 versions of the services.
11.5. URI Template Expressions Copy linkLink copied to clipboard!
Variables Copy linkLink copied to clipboard!
| Expression | Description |
|---|---|
{bundleName}
|
The name of the bundle that registers the Web service, servlet or application. This variable is currently not supported for Web services, but works for Web applications and servlets in an OSGi container. |
{bundleVersion}
|
The version of the bundle that registers the Web service, servlet or application. This variable is currently not supported for Web services, but works for Web applications and servlets in an OSGi container. |
{container}
|
The container ID of the container where the Web service or Web application is deployed. |
{contextPath}
|
The context path (the part of the URL after the host and port) of the Web service or Web application implementation. |
{servicePath}
|
The relative path within ZooKeeper that a service is registered. This is usually is made up of, for web services as the service name and version. For web applications its often the maven coordinates |
{version}
|
The profile version of the Web service or Web application. |
Chapter 12. Securing Fabric Containers Copy linkLink copied to clipboard!
Abstract
Default authentication system Copy linkLink copied to clipboard!
io.fabric8.jaas.ZookeeperLoginModule). This system allows you to define user accounts and assign passwords and roles to the users. Out of the box, the user credentials are stored in the Fabric registry, unencrypted.
Managing users Copy linkLink copied to clipboard!
jaas:* family of console commands. First of all you need to attach the jaas:* commands to the ZookeeperLoginModule login module, as follows:
jaas:* commands to the ZookeeperLoginModule login module. You can then add users and roles, using the jaas:useradd and jaas:roleadd commands. Finally, when you are finished editing the user data, you must commit the changes by entering the jaas:update command, as follows:
JBossFuse:karaf@root> jaas:update
JBossFuse:karaf@root> jaas:update
jaas:cancel.
Obfuscating stored passwords Copy linkLink copied to clipboard!
ZookeeperLoginModule stores passwords in plain text. You can provide additional protection to passwords by storing them in an obfuscated format. This can be done by adding the appropriate configuration properties to the io.fabric8.jaas PID and ensuring that they are applied to all of the containers in the fabric.
Enabling LDAP authentication Copy linkLink copied to clipboard!
LDAPLoginModule), which you can enable by adding the requisite configuration to the default profile.
Chapter 13. Configuring a Fabric's Maven Proxy Copy linkLink copied to clipboard!
Abstract
Overview Copy linkLink copied to clipboard!
Default repositories Copy linkLink copied to clipboard!
- Maven Central (http://repo1.maven.org/maven2)
- Fuse Releases (http://repo.fusesource.com/nexus/content/repositories/releases)
- Fuse Early Access (http://repo.fusesource.com/nexus/content/groups/ea)
- SpringSource (http://repository.springsource.com/maven/bundles/release, http://repository.springsource.com/maven/bundles/external)
- Scala Tools (
http://scala-tools.org/repo-releases) - User's Local (~/.m2/repository)
Changing the repositories Copy linkLink copied to clipboard!
- Create a new profile version.From the command console this is done using the fabric:version-create command. See section "Description" in "Console Reference"section "Description" in "Console Reference" for more information.
- Change the
org.ops4j.pax.url.mvn.repositoriesproperty in theio.fabric8.agentPID of thedefaultprofile. Example 13.1, “Configuring the Maven Proxy URL” shows the console command for editing this property.Example 13.1. Configuring the Maven Proxy URL
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteTheio.fabric8.agentPID is refined in all of the fabric profiles. Setting the proxy URL, theorg.ops4j.pax.url.mvn.repositoriesproperty, in thedefaultprofile ensures that all of the other fabric profiles share the same Maven proxy setting.ImportantThefabricprofile'sio.fabric8.mavenPID, which ultimately controls the Maven proxy, imports its value from thedefaultprofile'sio.fabric8.agentPID. You should not change the settings of theio.fabric8.mavenPID. - Roll the changes out the fabric by upgrading the containers to the new profile version.ImportantYou cannot test this configuration change out on a few containers to validate it. The change must be made to the entire fabric or it will result in conflicts.
Chapter 14. Offline Repositories Copy linkLink copied to clipboard!
Abstract
14.1. Offline Repository for a Profile Copy linkLink copied to clipboard!
Download into a specified directory Copy linkLink copied to clipboard!
ProfileName, enter the following console command:
fabric:profile-download --profile ProfileName /tmp/myrepo
fabric:profile-download --profile ProfileName /tmp/myrepo
/tmp/myrepo directory.
Download into the system folder Copy linkLink copied to clipboard!
fabric:profile-download command installs the files to the system folder inside the current Fuse container (thereby populating the local maven repository for the container). For example:
fabric:profile-download --profile ProfileName
fabric:profile-download --profile ProfileName
14.2. Offline Repository for a Version Copy linkLink copied to clipboard!
Download the current version Copy linkLink copied to clipboard!
fabric:profile-download /tmp/myrepo
fabric:profile-download /tmp/myrepo
Download a specific version Copy linkLink copied to clipboard!
--version option, as follows:
fabric:profile-download --version 1.0 /tmp/myrepo
fabric:profile-download --version 1.0 /tmp/myrepo
fabric:profile-download command installs the files into thesystem folder inside the current Fuse container (thereby populating the local maven repository for the container).
14.3. Offline Repository for a Maven Project Copy linkLink copied to clipboard!
Download repository for Maven project Copy linkLink copied to clipboard!
pom.xml file), you should be able to run the following Maven command:
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:go-offline -Dmaven.repo.local=/tmp/cheese
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:go-offline -Dmaven.repo.local=/tmp/cheese
/tmp/cheese directory.
Chapter 15. Patching Copy linkLink copied to clipboard!
15.1. Patching a Container in a Fabric Copy linkLink copied to clipboard!
Abstract
Overview Copy linkLink copied to clipboard!
Procedure Copy linkLink copied to clipboard!
- Getting a patch file.
- Customer Support sends you a patch.
- Customer Support sends you a link to download a patch.
- You, or your organization, generate a patch file for an internally created application.
- Uploading one or more patch files to the fabric's Maven repository.
- Applying the patch(es) to a profile version.This creates a new profile version that points to the new versions of the patched bundles and repositories.
- Migrate one or two containers to the patched profile version to ensure that the patch does not introduce any new issues.
- After you are certain that the patch works, migrate the remaining containers in the fabric to the patched version.
Using the management console Copy linkLink copied to clipboard!
Using the command console Copy linkLink copied to clipboard!
- Create a new version, using the
fabric:version-createcommand:JBossFuse:karaf@root> fabric:version-create 1.1 Created version: 1.1 as copy of: 1.0
JBossFuse:karaf@root> fabric:version-create 1.1 Created version: 1.1 as copy of: 1.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantThe version name must be a pure numeric string, such as1.1,1.2,2.1, or2.2. You cannot incorporate alphabetic characters in the version name (such as1.0.patch). - Apply the patch to the new version, using the
fabric:patch-applycommand. For example, to apply theactivemq.zippatch file to version1.1:JBossFuse:karaf@root> fabric:patch-apply --version 1.1 file:///patches/activemq.zip
JBossFuse:karaf@root> fabric:patch-apply --version 1.1 file:///patches/activemq.zipCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Upgrade the container using the
fabric:container-upgradecommand, specifying which container you want to upgrade. For example, to upgrade therootcontainer, enter the following command:JBossFuse:karaf@root> fabric:container-upgrade 1.1 root Upgraded container root from version 1.0 to 1.1
JBossFuse:karaf@root> fabric:container-upgrade 1.1 root Upgraded container root from version 1.0 to 1.1Copy to Clipboard Copied! Toggle word wrap Toggle overflow - You can check that the new patch profile has been created using the
fabric:profile-listcommand, as follows:BossFuse:karaf@root> fabric:profile-list --version 1.1 | grep patch default 0 patch-activemq-patch patch-activemq-patch
BossFuse:karaf@root> fabric:profile-list --version 1.1 | grep patch default 0 patch-activemq-patch patch-activemq-patchCopy to Clipboard Copied! Toggle word wrap Toggle overflow Where we presume that the patch was applied to profile version 1.1.TipIf you want to avoid specifying the profile version (with--version) every time you invoke a profile command, you can change the default profile version using thefabric:version-set-default Versioncommand.You can also check whether specific JARs are included in the patch, for example:JBossFuse:karaf@root> list | grep -i activemq [ 131] [Active ] [Created ] [ ] [ 50] activemq-osgi (5.9.0.redhat-61037X) [ 139] [Active ] [Created ] [ ] [ 50] activemq-karaf (5.9.0.redhat-61037X) [ 207] [Active ] [ ] [ ] [ 60] activemq-camel (5.9.0.redhat-61037X)
JBossFuse:karaf@root> list | grep -i activemq [ 131] [Active ] [Created ] [ ] [ 50] activemq-osgi (5.9.0.redhat-61037X) [ 139] [Active ] [Created ] [ ] [ 50] activemq-karaf (5.9.0.redhat-61037X) [ 207] [Active ] [ ] [ ] [ 60] activemq-camel (5.9.0.redhat-61037X)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Appendix A. Editing Profiles with the Built-In Text Editor Copy linkLink copied to clipboard!
Abstract
profile-edit command with no arguments except for the profile's name (and optionally, version); or adding the --pid option for editing OSGi PID properties; or adding the --resource option for editing general resources.
A.1. Editing Agent Properties Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Open the agent properties resource Copy linkLink copied to clipboard!
JBossFuse:karaf@root> profile-edit Profile [Version]
JBossFuse:karaf@root> profile-edit Profile [Version]
Profile is the name of the profile to edit and you can optionally specify the profile version, Version, as well. The text editor opens in the console window, showing the current profile name and version in the top-left corner of the Window. The bottom row of the editor screen summarizes the available editing commands and you can use the arrow keys to move about the screen.
Specifying feature repository locations Copy linkLink copied to clipboard!
repository.ID=URL
repository.ID=URL
ID is an arbitrary unique identifier and URL gives the location of a single feature repository (only one repository URL can be specified on a line).
Specifying deployed features Copy linkLink copied to clipboard!
feature.ID=FeatureName
feature.ID=FeatureName
ID is an arbitrary unique identifier and FeatureName is the name of a feature.
Specifying deployed bundles Copy linkLink copied to clipboard!
bundle.ID=URL
bundle.ID=URL
ID is an arbitrary unique identifier and URL specifies the bundle's location.
blueprint: (or spring:) URL handler to deploy a Blueprint XML resource (or a Spring XML resource) as an OSGi bundle.
Specifying bundle overrides Copy linkLink copied to clipboard!
override.ID=URL
override.ID=URL
ID is an arbitrary unique identifier and URL specifies the bundle's location.
Specifying deployed FABs Copy linkLink copied to clipboard!
fab.ID=URL
fab.ID=URL
ID is an arbitrary unique identifier and URL specifies the FAB's location.
Specifying etc/config.properties properties Copy linkLink copied to clipboard!
etc/config.properties in a standalone container), add a line in the following format:
config.Property=Value
config.Property=Value
Specifying etc/system.properties properties Copy linkLink copied to clipboard!
etc/system.properties in a standalone container), add a line in the following format:
system.Property=Value
system.Property=Value
Property, is already set at the JVM level (for example, through the --jvm-opts option to the fabric:container-create command), the preceding fabric:profile-edit command will not override the JVM level setting. To override a JVM level setting, set the system property as follows:
system.karaf.override.Property=Value
system.karaf.override.Property=Value
Specifying libraries to add to Java runtime lib/ Copy linkLink copied to clipboard!
lib/ directory of the underlying Java runtime), add a line in the following format:
lib.ID=URL
lib.ID=URL
ID is an arbitrary unique identifier and URL specifies the library's location.
Specifying libraries to add to Java runtime lib/ext/ Copy linkLink copied to clipboard!
lib/ext/ directory of the underlying Java runtime), add a line in the following format:
ext.ID=URL
ext.ID=URL
ID is an arbitrary unique identifier and URL specifies the extension library's location.
Specifying libraries to add to Java runtime lib/endorsed/ Copy linkLink copied to clipboard!
lib/endorsed/ directory of the underlying Java runtime), add a line in the following format:
endorsed.ID=URL
endorsed.ID=URL
ID is an arbitrary unique identifier and URL specifies the endorsed library's location.
Example Copy linkLink copied to clipboard!
mq-client profile's agent properties for editing, enter the following console command:
JBossFuse:karaf@root> profile-edit mq-client
JBossFuse:karaf@root> profile-edit mq-client
^X to quit the text editor and get back to the console prompt.
A.2. Editing OSGi Config Admin Properties Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Persistent ID Copy linkLink copied to clipboard!
PID persistent ID are defined in the PID.properties resource.
Open the Config Admin properties resource Copy linkLink copied to clipboard!
PID persistent ID, enter the following console command:
JBossFuse:karaf@root> profile-edit --pid PID Profile [Version]
JBossFuse:karaf@root> profile-edit --pid PID Profile [Version]
--resource PID.properties in the profile-edit command, instead of using the --pid PID option.
Specifying OSGi config admin properties Copy linkLink copied to clipboard!
PID.properties resource (which is actually stored in the ZooKeeper registry). To edit the properties, add, modify, or delete lines of the following form:
Property=Value
Property=Value
Example Copy linkLink copied to clipboard!
io.fabric8.hadoop PID in the hadoop-base profile, enter the following console command:
JBossFuse:karaf@root> profile-edit --resource io.fabric8.hadoop.properties hadoop-base 1.0
JBossFuse:karaf@root> profile-edit --resource io.fabric8.hadoop.properties hadoop-base 1.0
\:). Strictly speaking, it is only necessary to escape a colon if it appears as part of a property name (left hand side of the equals sign), but the profile-edit command automatically escapes all colons when it writes to a resource. When manually editing resources using the text editor, however, you do not need to escape colons in URLs appearing on the right hand side of the equals sign.
^X to quit the text editor and get back to the console prompt.
A.3. Editing Other Resources Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Creating and editing an arbitrary resource Copy linkLink copied to clipboard!
JBossFuse:karaf@root> profile-edit --resource Resource Profile [Version]
JBossFuse:karaf@root> profile-edit --resource Resource Profile [Version]
Resource is the name of the profile resource you want to edit. If Resource does not already exist, it will be created.
broker.xml example Copy linkLink copied to clipboard!
mq-base profile has the broker.xml resource, which stores the contents of an Apache ActiveMQ broker configuration file. To edit the broker.xml resource, enter the following console command:
JBossFuse:karaf@root> profile-edit --resource broker.xml mq-base 1.0
JBossFuse:karaf@root> profile-edit --resource broker.xml mq-base 1.0
^X to quit the text editor and get back to the console prompt.
Referencing a profile resource Copy linkLink copied to clipboard!
broker.xml resource from the previous example is stored under the following ZooKeeper location:
zk:/fabric/configs/versions/1.0/profiles/mq-base/broker.xml
zk:/fabric/configs/versions/1.0/profiles/mq-base/broker.xml
Version, of the Profile profile's Resource resource at the following location:
zk:/fabric/configs/versions/Version/profiles/Profile/Resource
zk:/fabric/configs/versions/Version/profiles/Profile/Resource
mq profile's org.fusesource.mq.fabric.server-broker PID defines the following properties, where the config property references the broker.xml resource:
connectors=openwire config=zk\:/fabric/configs/versions/1.0/profiles/mq-base/broker.xml group=default standby.pool=default
connectors=openwire
config=zk\:/fabric/configs/versions/1.0/profiles/mq-base/broker.xml
group=default
standby.pool=default
A.4. Profile Attributes Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
parents attribute Copy linkLink copied to clipboard!
parents attribute is a list of one or more parent profiles. This attribute can be set using the profile-change-parents console command. For example, to assign the parent profiles camel and cxf to the my-camel-cxf-profile profile, you would enter the following console command:
JBossFuse:karaf@root> profile-change-parents --version 1.0 my-camel-cxf-profile camel cxf
JBossFuse:karaf@root> profile-change-parents --version 1.0 my-camel-cxf-profile camel cxf
abstract attribute Copy linkLink copied to clipboard!
abstract attribute is set to true, the profile cannot be directly deployed to a container. This is useful for profiles that are only intended to be the parents of other profiles—for example, mq-base. You can set the abstract attribute from the Management Console.
locked attribute Copy linkLink copied to clipboard!
hidden attribute Copy linkLink copied to clipboard!
hidden attribute is a flag that is typically set on profiles that Fuse Fabric creates automatically (for example, to customize the setup of a registry server). By default, hidden profiles are not shown when you run the profile-list command, but you can see them when you add the --hidden flag, as follows:
Appendix B. Fabric URL Handlers Copy linkLink copied to clipboard!
Abstract
B.1. Profile URL handler Copy linkLink copied to clipboard!
profile:ResourceName
profile:ResourceName
- The profile URL handler first tries to find the named resource,
ResourceName, in the current version of the current profile (where the current version is a property of the container in which the profile is running). - If the specified resource is not found in the current profile, the profile URL tries to find the resource in the current version of the parent profile.
fabric:container-upgrade or fabric:container-rollback console commands), the referenced resources are also, automatically, upgraded or rolled back.
B.2. Zk URL handler Copy linkLink copied to clipboard!
zk:/PathToNode
zk:/PathToNode
zk:ContainerName/Property
zk:ContainerName/Property
zk:/fabric/registry/containers/config/ContainerName/Property
zk:/fabric/registry/containers/config/ContainerName/Property
B.3. Blueprint URL handler Copy linkLink copied to clipboard!
blueprint: scheme can be prefixed to any of the usual location URL handlers (for example, file:, http:, profile:, zk:).
bundle entry in the agent properties (equivalent to the io.fabric8.agent PID) in the following format:
bundle.ID=blueprint:LocationScheme:LocationOfBlueprintXML
bundle.ID=blueprint:LocationScheme:LocationOfBlueprintXML
example-camel-hello profile's agent properties include the following bundle entry:
bundle.camel-fabric=blueprint:profile:camel.xml
bundle.camel-fabric=blueprint:profile:camel.xml
B.4. Spring URL handler Copy linkLink copied to clipboard!
spring: scheme can be prefixed to any of the usual location URL handlers (for example, file:, http:, profile:, zk:).
bundle entry in the agent properties (equivalent to the io.fabric8.agent PID) in the following format:
bundle.ID=spring:LocationScheme:LocationOfBlueprintXML
bundle.ID=spring:LocationScheme:LocationOfBlueprintXML
camel-spring.xml, from the current profile, you could add the following entry to the profile's agent properties:
bundle.spring-resource=spring:profile:camel-spring.xml
bundle.spring-resource=spring:profile:camel-spring.xml
Appendix C. Profile Property Resolvers Copy linkLink copied to clipboard!
Abstract
${ResourceReference}. This variable substitution mechanism can be used in any profile resource, including the agent properties, PID properties, and other resources—for example, the mq-base profile's broker.xml resource references the ${broker.name} and ${data} variables.
C.1. Substituting system properties Copy linkLink copied to clipboard!
Syntax Copy linkLink copied to clipboard!
${PropName}
${PropName}
PropName can be the name of any Java system property. In particular, Java system properties can be defined in the following locations:
- The
etc/system.propertiesfile, relative to the container's home directory. - System property settings in the profile's agent properties.
etc/system.properties file are, as follows:
| System Property | Description |
|---|---|
${karaf.home} | The directory where Red Hat JBoss Fuse is installed. |
${karaf.data} | Location of the current container's data directory, which is usually ${karaf.home}/data for a main container or ${karaf.home}/instances/InstanceName/data for a child container. |
${karaf.name} | The name of the current container. |
C.2. Substituting environment variables Copy linkLink copied to clipboard!
Syntax Copy linkLink copied to clipboard!
${env:VarName}
${env:VarName}
C.3. Substituting container attributes Copy linkLink copied to clipboard!
Syntax Copy linkLink copied to clipboard!
${container:Attribute}
${container:Attribute}
| Attribute | Description |
|---|---|
${container:resolver} | The effective resolver policy for the current container. Possible values are: localip, localhostname, publicip, publichostname, manualip. |
${container:ip} | The effective IP address used by the current container, which has been selected by applying the resolver policy. This is the form of host address that is advertised to other containers and applications. |
${container:localip} | The numerical IP address of the current container, which is suitable for accessing the container on a LAN. |
${container:localhostname} | The host name of the current container, which is suitable for accessing the container on a LAN. |
${container:publicip} | The numerical IP address of the current container, which is suitable for accessing the container from a WAN (on the Internet). |
${container:publichostname} | The host name of the current container, which is suitable for accessing the container from a WAN (on the Internet). |
${container:manualip} | An IP address that is specified manually, by setting the value of the relevant node in the ZooKeeper registry. |
${container:bindaddress} | |
${container:sshurl} | The URL of the SSH service, which can be used to log on to the container console. |
${container:jmxurl} | The URL of the JMX service, which can be used to monitor the container. |
${container:jolokiaurl} | The URL of the Jolokia service, which is used by the Fuse Management Console to access the container. |
${container:httpurl} | The base URL of the container's default Jetty HTTP server. |
${container:domains} | List of JMX domains registered by the container. |
${container:processid} | Returns the process ID of the container process (on Linux-like and UNIX-like operating systems). |
${container:openshift} | A boolean flag that returns true, if the container is running on OpenShift; otherwise, false. |
${container:blueprintstatus} | The aggregate status of all the deployed Blueprint contexts. If all of the deployed contexts are ok, the status is ok; if one or more deployed contexts have failed, the status is failed. |
${container:springstatus} | The aggregate status of all the deployed Spring contexts. If all of the deployed contexts are ok, the status is ok; if one or more deployed contexts have failed, the status is failed. |
${container:provisionstatus} | Returns the container provision status. |
${container:provisionexception} | If the container provisioning has failed, this variable returns the provisioning exception. |
${container:provisionlist} | The list of provisioned artefacts in the container. |
${container:geolocation} | The geographic location of the container (which is obtained by making a Web request to a public service that gives the GPS coordinates of the container host). |
C.4. Substituting PID properties Copy linkLink copied to clipboard!
Syntax Copy linkLink copied to clipboard!
${profile:PID/Property}
${profile:PID/Property}
Example using a profile property resolver Copy linkLink copied to clipboard!
fabric profile's io.fabric8.maven.properties PID resource includes the following property setting:
remoteRepositories=${profile:io.fabric8.agent/org.ops4j.pax.url.mvn.repositories}
remoteRepositories=${profile:io.fabric8.agent/org.ops4j.pax.url.mvn.repositories}
remoteRepositories property is set to the value of the org.ops4j.pax.url.mvn.repositories agent property (io.fabric8.agent is the PID for the agent properties).
C.5. Substituting ZooKeeper node contents Copy linkLink copied to clipboard!
Syntax Copy linkLink copied to clipboard!
${zk:/PathToNode}
${zk:/PathToNode}
${zk:ContainerName/Property}
${zk:ContainerName/Property}
${zk:/fabric/registry/containers/config/ContainerName/Property}
${zk:/fabric/registry/containers/config/ContainerName/Property}
Recursive variable substitution Copy linkLink copied to clipboard!
dosgi profile's io.fabric8.dosgi.properties resource defines the following property:
exportedAddress=${zk:${karaf.name}/ip}
exportedAddress=${zk:${karaf.name}/ip}
How to reference the current version of a resource Copy linkLink copied to clipboard!
my-profile profile's my-resource resource, which can be done using the following ZooKeeper URL:
${zk:/fabric/configs/versions/1.0/profiles/my-profile/my-resource}
${zk:/fabric/configs/versions/1.0/profiles/my-profile/my-resource}
1.0, is embedded in this path. But if you decide to upgrade this profile to version 1.1, this means you must manually edit all occurrences of this ZooKeeper URL, changing the version number to 1.1 in order to reference the upgraded resource. To avoid this extra work, and to ensure that the resolver always references the current version of the resource, you can use the following trick which exploits recursive variable substitution:
${zk:/fabric/configs/versions/${zk:/fabric/configs/containers/${karaf.name}}/profiles/my-profile/my-resource}
${zk:/fabric/configs/versions/${zk:/fabric/configs/containers/${karaf.name}}/profiles/my-profile/my-resource}
/fabric/configs/containers/${karaf.name} ZooKeeper node contains the current profile version deployed in the container.
C.6. Checksum property resolver Copy linkLink copied to clipboard!
Syntax Copy linkLink copied to clipboard!
checksum: scheme can be prefixed to any of the usual location URL handlers (for example, file:, http:, profile:, zk:).
default profile defines the following checksum property in the org.ops4j.pax.web PID:
org.ops4j.pax.web.config.checksum=${checksum:profile\:jetty.xml}
org.ops4j.pax.web.config.checksum=${checksum:profile\:jetty.xml}
C.7. Port property resolver Copy linkLink copied to clipboard!
Syntax Copy linkLink copied to clipboard!
${port:Min,Max}
${port:Min,Max}
Min and Max specify the minimum and maximum values of the allocated IP port.
Appendix D. Technology-specific Discovery Mechanisms Copy linkLink copied to clipboard!
Abstract
D.1. ActiveMQ endpoint discovery Copy linkLink copied to clipboard!
discovery:(fabric:us-east)
discovery:(fabric:us-east)
us-east represents a cluster of brokers deployed in the us-east cloud.
D.2. Camel endpoint discovery Copy linkLink copied to clipboard!
fabric:- The
fabric:prefix provides location transparency and load-balancing functionality for Camel endpoints. A consumer endpoint (acting like a server port), defines its endpoint URI using the following syntax:fabric:ClusterID:EndpointURI
fabric:ClusterID:EndpointURICopy to Clipboard Copied! Toggle word wrap Toggle overflow So that the Camel endpoint URI,EndpointURI, is stored in the Fabric registry under the cluster ID, ClusterID. Producer endpoints (acting like clients) can then access the Camel endpoint by specifying just the ClusterID, as follows:fabric:ClusterID
fabric:ClusterIDCopy to Clipboard Copied! Toggle word wrap Toggle overflow Fabric then resolves the cluster ID to the registered endpoint URI. If multiple endpoint URIs are registered under the same cluster ID, Fabric randomly selects one of the available URIs, thus providing load-balancing functionality. master:- The
master:prefix provides failover functionality for Camel endpoints. Two or more consumer endpoints (server ports) must register their URIs with the Fabric registry, using the following syntax:master:ClusterID:EndpointURI
master:ClusterID:EndpointURICopy to Clipboard Copied! Toggle word wrap Toggle overflow Producer endpoints (acting like clients) can then access the failover cluster by defining a URI with the following syntax:master:ClusterID
master:ClusterIDCopy to Clipboard Copied! Toggle word wrap Toggle overflow Initially, Fabric chooses one of the consumer endpoints to be the master instance and always resolves the client URIs to this master location. If the master fails, however, Fabric will fail over to one of the other registered endpoint URIs and start resolving to that endpoint instead.
D.3. CXF endpoint discovery Copy linkLink copied to clipboard!
D.4. OSGi service discovery Copy linkLink copied to clipboard!
service.exported.interfaces property (having a value of * or an explicit list of interfaces to export) is automatically exported to the Fabric registry and becomes accessible to other remote containers in the same fabric.
Legal Notice Copy linkLink copied to clipboard!
Trademark Disclaimer
Legal Notice Copy linkLink copied to clipboard!
Third Party Acknowledgements
- JLine (http://jline.sourceforge.net) jline:jline:jar:1.0License: BSD (LICENSE.txt) - Copyright (c) 2002-2006, Marc Prud'hommeaux
mwp1@cornell.eduAll rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of JLine nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - Stax2 API (http://woodstox.codehaus.org/StAX2) org.codehaus.woodstox:stax2-api:jar:3.1.1License: The BSD License (http://www.opensource.org/licenses/bsd-license.php)Copyright (c) <YEAR>, <OWNER> All rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - jibx-run - JiBX runtime (http://www.jibx.org/main-reactor/jibx-run) org.jibx:jibx-run:bundle:1.2.3License: BSD (http://jibx.sourceforge.net/jibx-license.html) Copyright (c) 2003-2010, Dennis M. Sosnoski.All rights reserved.Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of JiBX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - JavaAssist (http://www.jboss.org/javassist) org.jboss.javassist:com.springsource.javassist:jar:3.9.0.GA:compileLicense: MPL (http://www.mozilla.org/MPL/MPL-1.1.html)
- HAPI-OSGI-Base Module (http://hl7api.sourceforge.net/hapi-osgi-base/) ca.uhn.hapi:hapi-osgi-base:bundle:1.2License: Mozilla Public License 1.1 (http://www.mozilla.org/MPL/MPL-1.1.txt)