---
title: Getting Started with Fuse Fabric
in_menu: true
sort_info: 10
--- pipeline:jade

.row-fluid
  .span4
    :markdown
      ## Install
  .span8
    :&markdown
      To install Fuse Fabric 
  
      * [download](../download.html) the Fuse Fabric distro 
      * [checkout](../../source.html) and [build](../../building.html) the Fabric distro locally and untar the fabric/fabric8-karaf tarball
  

.row-fluid
  .span4
    :markdown
      ## Start Fuse Fabric
  .span8
    :&markdown
      To start Fuse Fabric use the following commands from a shell 

    pre
      | bin/fusefabric           (for Unix systems)
      | bin\fusefabric.bat       (for Windows systems)    
    
    :&markdown
      Fuse Fabric will present itself on the console as shown below
    pre
      | fuse-fabric-#{project_version}$ bin/fusefabric 
      | ______                  ______      _            _       
      | |  ___|                 |  ___|    | |          (_)      
      | | |_  _   _  ___   ___  | |_  __ _ | |__   _ __  _   ___ 
      | |  _|| | | |/ __| / _ \ |  _|/ _` || '_ \ | '__|| | / __|
      | | |  | |_| |\__ \|  __/ | | | (_| || |_) || |   | || (__ 
      | \_|   \__,_||___/ \___| \_|  \__,_||_.__/ |_|   |_| \___|
      |   Fuse Fabric Container (#{project_version})
      |   http://fuse.fusesource.org/fabric/
      |
      | Hit '<tab>' for a list of available commands
      | and '[cmd] --help' for help on a specific command.
      | Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown this Fuse Fabric Container.
      |
      | Create a new Fabric via 'fabric:create'
      | or join an existing Fabric via 'fabric:join [someUrls]'
      |
      | FuseFabric:admin@root> 

.row-fluid
  .span4
    :markdown
      ## Create a Fabric
  .span8
    :&markdown
      Create a new fabric on your machine via the **fabric:create** command.

    pre
      | FuseFabric:admin@root> fabric:create

    :&markdown
      This creates initial Fabric registry (running a local ZooKeeper server) and importing all the default profiles.

      You may be prompted for creating a new user. This user will be used for ssh, jmx and http access to your containers. See more at [fabric sercurity](fabric-security.html)
      
      The initial profile data all comes from the [fabric/import](https://github.com/fusesource/fuse/tree/master/fabric/fabric8-karaf/src/main/resources/distro/fabric/import) directory.

      You can then view the available profiles via **profile-list**

    pre
      | FuseFabric:admin@root> profile-list
      | [id]                           [parents]
      | ode                            servicemix
      | hadoop-namenode                
      | mq                             karaf
      | example-camel                  examples, karaf
      | esb                            mq, nmr, camel
      | hadoop-datanode                
      | hadoop                         
      | example-mq                     examples
      | camel                          karaf
      | default                        
      | nmr                            karaf
      | karaf                          default
      | fabric-ensembler-0000-1        fabric-ensemble-0000
      | fabric-ensemble-0000

    :&markdown
      Or list the available containers via **container-list**

    pre
      | FuseFabric:admin@root> container-list
      | [id]                           [alive]    [profiles]                       [provision status]
      | root                           true       default, fabric-ensemble-0000-1  success

.row-fluid
  .span4
    :markdown
      ## Create a Broker process 
  .span8
    :&markdown
      Lets start by creating a message broker using the default **mq** profile as a child container on the **root** process, and naming the container **broker1**.
      Child containers are separate JVMs which can be connected to via the shell or JMX and started/stopped independently.

    pre
      | FuseFabric:karaf@root> container-create-child --profile mq root broker1
      | ...

    :&markdown
      Check that the container has been created (it can take a few seconds):  

    pre
      | FuseFabric:admin@root> fabric:container-list
      | [id]                           [alive]    [profiles]                     [provision status]                                                                                  
      | root                           true       default, fabric-ensemble-0000-1
      | &nbsp;&nbsp;broker1                      true       mq                             success                                                                                             

    :&markdown
      Check that the container has been created (it can take a few seconds):  

    pre
      | FuseFabric:admin@test> help activemq:list
      | ...

    :&markdown
      The message broker provides a set of commands (**activemq**) you can use to access details from the broker.
      For example running **activemq:list** will show the broker names running on the container:

    pre
      | admin@broker1> activemq:list
      | BrokerName = broker1

.row-fluid
  .span4
    :markdown
      ## Exit an Container 
  .span8
    :&markdown
      After creating the message broker, we want to disconnect the container, to return to Fuse Fabric.
      You can do this by pressing `ctrl + d` in the console, or run the **logout** command:

    pre
      | FuseFabric:karaf@root> logout
      | ...
  

.row-fluid
  .span4
    :markdown
      ## Create a Camel process 
  .span8
    :&markdown
      Now lets create a separate container running a Camel route using the default **example-camel** profile as a child container on the **root** process.

    pre
      | FuseFabric:karaf@root> container-create-child --profile example-camel root camel1
      | ...

    :&markdown
      Check that the container has been created and started (it can take a few seconds). You can run the **container-list** command repeatably to see the current stats:  

    pre
      | FuseFabric:admin@root> container-list
      | [id]                           [alive]    [profiles]                     [provision status]                                                                                  
      | root                           true       default, fabric-ensemble-0000-1
      | &nbsp;&nbsp;broker1                      true       mq                             success                                                                                             
      | &nbsp;&nbsp;camel1                       true       example-camel                  success
  
    :&markdown
      Now we should be able to connect to it and list the Camel routes

    pre
      | FuseFabric:admin@root> container-connect camel1
      | ...
      | admin@camel1> camel:list-routes 
      | [route1              ]
      | [route2              ]

.row-fluid
  .span4
    :markdown
      ## Running Camel Example 
  .span8
    :&markdown
      The **example-camel** example which we just installed, will every 5th second send a message to the message broker. And the consume
      the message and print it to the log. This is implemented using the two Camel routes, which you can view in more details using **camel:info-route route1**

    pre
      | admin@camel1> camel:info-route route1
      | ... 

    :&markdown
      Among the details will be statistics for number of messages processed, represented as `Exchanges Total`. We can now logout from the *camel1* container
      and connect to the message broker:

    pre
      | admin@camel1> logout
      | ...
      | FuseFabric:admin@root> container-connect broker1
      | ...

    :&markdown
      From the message broker container, we can view statistics from the message broker, such as the `camel-test` queue which is used by the example.
      The following command shows a number of stats for the given queue.

    pre
      | admin@broker1> activemq:query -QQueue=camel-test
      | ...

.row-fluid
  .span4
    :markdown
      ## Stopping Containers and Fuse Fabric
  .span8
    :&markdown
      You can manage containers from the Fuse Fabric shell. For example to stop the **camel1** container, you can do as shown below.
      Remember you have to in the Fuse Fabric shell, which you can notice in the prompt. If you are connected to another container, you
      can logout from the container, to get back to the Fuse Fabric container.

    pre
      | FuseFabric:admin@root> container-stop camel1
      | ... 

    :&markdown
      Stopping Fuse Fabric can be done from the shell, JMX or from the OS command line. From the shell you can issue the **shutdown** command,
      and enter yes in the prompt:

    pre
      | FuseFabric:admin@root> shutdown
      | Confirm: shutdown instance root (yes/no):
      | ... 

    :&markdown
      Congratulations, you are now started with Fuse Fabric, and have successfully managed to install two child containers. Install an example, which
      exchanges messages between the containers using the message broker.

.row-fluid
  .span4
    :markdown
      ## Install Fuse Fabric in a vanilla container
  .span8
    :&markdown
      Fuse Fabric can be installed in a vanilla container such as Apache Karaf or ServiceMix.
      Run the following sequence of commands in an Apache Karaf (2.2.x) or ServiceMix (4.x) console:

      Notice: You cannot use Karaf 2.2.5 as it has an issue, that is being fixed in 2.2.6  

    pre
      | karaf@root> features:addUrl mvn:io.fabric8/fabric8/#{project_version}/xml/features
      | karaf@root> features:install fabric-boot-commands

    :&markdown
      The above command will install the necessary commands to create a fabric or join an existing fabric

      If you are using a SNAPSHOT version of Fabric, and have not built Fabric locally, then you must add the Maven repositories list,
      the location of where the Fabric SNAPSHOT artifacts is installed.
      In the "etc/org.ops4j.pax.url.mvn.cfg" file add the following entries to the "org.ops4j.pax.url.mvn.repositories" key:

    pre
      | https://repo.fusesource.com/nexus/content/repositories/snapshots@snapshots, \
      | https://repo.fusesource.com/nexus/content/groups/public


