|
This note has been tested with Ant 1.8 and Groovy 1.8, with Tibco Runtime Agent (TRA) 5.6.
For fault tolerant running engines there must be an element services/bw/bindings/binding/ftWeight for each BW engine in the AppManage xml file and an element services/bw/bwprocesses/isFt equal to true. Furthermore there should be an element services/bw/bwprocesses/faultTolerant in the same file:
<faultTolerant>
<hbInterval>10000</hbInterval>
<activationInterval>35000</activationInterval>
<preparationDelay>0</preparationDelay>
</faultTolerant>
In addition the tra file needs to have Rendezvous settings such that the BW instances can signal whether they are active or standby:
- Bus.Default.Daemon=tcp\:7474
- Bus.Default.Service=7500
This can be accomplished by adding the following xml tag to your file <BW-installationDir>/bin/bwengine.xml on your local desktop and then use Tibco Designer to build the ear file:
<property>
<name>Default RV Daemon</name>
<option>Bus.Default.Daemon</option>
<default>tcp:7474</default>
<description>Default RV Daemon</description>
</property>
It is also possible to directly edit the tra files after each deployment. In that case it is better to deploy with AppManage from ant without starting the BW engine, add an ant target to modify the tra file and finally use an ant target calling AppManage to start the BW engines. The ant target modifying the tra files is shown below:
<target name="addFaultToleranceToTra">
<groovy>
<![CDATA[
def bwHostsList = properties.get("bw.hosts.list").split(",");
def sshUser = properties.get("sshUser")
def passwordList=properties.get("ssh.password.list").split(",");
def tibcoInstallationDir = properties.get("tibco.server.installationDir")
def tibcoDomainDir = tibcoInstallationDir +"/tra/domain/" +properties.get("tibco.admin.domain")
def packageName = properties.get("source.packagename")
def traDir = tibcoDomainDir +"/application/" +packageName
def i = 0 // instanceId counter
for (bwHost in bwHostList) {
def instanceId = i==0 ? '' : '-' +i
filename = packageName +"-" +packageName +instanceId +".tra"
ant.scp(
trust:true,
file: sshUser +":" +passwordList[i] +"@" +bwHost +":" +traDir +"/" +filename,
todir: "."
){}
ant.copy(file: filename, tofile:filename +"_orig" +properties.get("BUILD_ID")){}
ant.propertyfile(
file:filename
) {
// modify the tra file to make the engines fault tolerant,
// must be enabled in the deployment xml as well
entry(key: "Bus.Default.Daemon", value:"tcp:7474")
entry(key: "Bus.Default.Service", value:"7500")
}
ant.scp(
trust:true,
todir: sshUser +":" +passwordList[i] +"@" +bwHost +":" ++traDir +"/" +packageName,
file: filename
){}
i = i+1
} // end of loop over bwHosts
]]>
</groovy>
</target>
Note the usage of properties to get BW hosts, passwords and the BW deployment name. Instead of using properties for server passwords and BusinessWorks host names one could also use ssh trusted key authentication to log in and extract the BW host names from the deployment xml file, e.g. within Groovy with XmlSlurper.
The ant task uses the fact that Tibco tra files are in fact Ant property files. That means that adding and modifying properties within tra files is straightforward with the Ant propertyfile task.
Of course the ant code above can be executed by calling ant from the command line. But it is much easier to set up a build system such as Jenkins and then call the script from its web front-end with just a single click.
|