1.1.4. Farming Deployment

1.1.4. Farming Deployment

The easiest way to deploy an application into the cluster is to use the farming service. That is to hot-deploy the application archive file (e.g., the EAR, WAR or SAR file) in the all/farm/ directory of any of the cluster member and the application is automatically duplicated across all nodes in the same cluster. If node joins the cluster later, it will pull in all farm deployed applications in the cluster and deploy them locally at start-up time. If you delete the application from one of the running cluster server node's farm/ folder, the application will be undeployed locally and then removed from all other cluster server nodes farm folder (triggers undeployment.) You should manually delete the application from the farm folder of any server node not currently connected to the cluster.

Note

Currently, due to an implementation bug, the farm deployment service only works for hot-deployed archives. If you put an application in the farm/ directory first and then start the server, the application would not be detected and pushed across the cluster. We are working to resolve this issue.

Note

You can only put archive files, not exploded directories, in the farm directory. This way, the application on a remote node is only deployed when the entire archive file is copied over. Otherwise, the application might be deployed (and failed) when the directory is only partially copied.

Farming is enabled by default in the all configuration in JBoss AS distributions, so you will not have to set it up yourself. The configuration file is located in the deploy/deploy.last directory. If you want to enable farming in your custom configuration, simply create the XML file shown below (named it farm-service.xml) and copy it to the JBoss deploy directory $JBOSS_HOME/server/your_own_config/deploy. Make sure that you custom configuration has clustering enabled.

<?xml version="1.0" encoding="UTF-8"?>    
<server>        
        
    <mbean code="org.jboss.ha.framework.server.FarmMemberService"     
            name="jboss:service=FarmMember,partition=DefaultPartition">     
        ...      
        <attribute name="PartitionName">DefaultPartition</attribute>      
        <attribute name="ScanPeriod">5000</attribute>      
        <attribute name="URLs">farm/</attribute>     
    </mbean>       
</server>
            

After deploying farm-service.xml you are ready to rumble. The required FarmMemberService MBean attributes for configuring a farm are listed below.

The Farming service is an extension of the URLDeploymentScanner, which scans for hot deployments in deploy/ directory. So, you can use all the attributes defined in the URLDeploymentScanner MBean in the FarmMemberService MBean. In fact, the URLs and ScanPeriod attributes listed above are inherited from the URLDeploymentScanner MBean.