Red Hat Training
A Red Hat training course is available for Red Hat Fuse
Chapter 4. Fabric Containers
4.1. Child Containers
Child containers are the easiest kind of container to create. They are created on the same host as an existing container and are piggybacked on the same JBoss Fuse installation.
If you want to run multiple JBoss Fuse containers on a single physical host, typically the best approach is to create child containers. A child container is a relatively lightweight way to create a new container, because it re-uses most of the files in a JBoss Fuse installation. It is also convenient for administration, because the children are defined to have a parent container, so that the containers form an orderly hierarchy.
One container or many?
In principle, a single OSGi container can host multiple applications (even applications with different dependencies). So, why might you need to define extra child containers on the same host? One reason for using child containers is simply to provide a degree of isolation between applications or between components of an application. A child container runs in its own JVM process, so it is well insulated from other containers running on the same host. Using child containers also gives your application a coarse-grained structure that can be useful for managing the system (for example, each child container can be independently stopped and started).
Creating a child container
To create a new child container, invoke the
fabric:container-create-childcommand, specifying the parent container name and the name of the new child container. For example, to create the new child container,
rootas its parent, enter the following command:
fabric:container-create-child root onlychild
If you want to create multiple child containers, an easy way to do this is to add an extra parameter, which specifies the number of new children. For example, to create three new child containers, enter a command like the following:
fabric:container-create-child root child 3
The preceding command would create the following new child containers:
child1 child2 child3
Stopping and starting a child container
Because each child container runs as a separate process, its lifecycle is independent of the parent container. That is, when you shut down a parent container, it does not automatically shut down the children. To shut down a child container, you must explicitly invoke the
fabric:container-stopcommand. For example, to shut down the
To restart a stopped child container, invoke the
fabric:container-startcommand, as follows:
You can also stop a child container using the standard UNIX process management utilities,
Deleting a child container
To delete a child container (that is, permanently removing all trace of the container from the fabric, including Fabric registry entries, and data stored in the local filesystem), invoke the
fabric:container-deletecommand, as follows:
Using a wildcard, you can delete all child containers; for example,