Sample Ant tasks for MFT

There are a number of sample Ant scripts provided with your installation of Managed File Transfer. These samples are located in the directory MQ_INSTALLATION_PATH/mqft/samples/fteant. Each sample script contains an init target, edit the properties set in the init target to run these scripts with your configuration.


email

The email sample demonstrates how to use Ant tasks to transfer a file and send an email to a specified email address if the transfer fails. The script checks that the source and destination agents are active and able to process transfers by using the Managed File Transfer ping task. If both agents are active, the script uses the Managed File Transfer fte:filecopy task to transfer a file between the source and destination agents, without deleting the original file. If the transfer fails the script sends an email containing information about the failure by using the standard Ant email task.


hub

The hub sample is made up of two scripts: hubcopy.xml and hubprocess.xml. The hubcopy.xml script shows how we can use Ant scripting to build 'hub and spoke' style topologies. In this sample, two files are transferred from agents running on spoke machines to an agent running on the hub machine. Both files are transferred at the same time, and when the transfers are complete the hubprocess.xml Ant script is run on the hub machine to process the files. If both files transfer correctly, the Ant script concatenates the contents of the files. If the files do not transfer correctly, the Ant script cleans up by deleting any file data that was transferred. For this example to work correctly, we must put the hubprocess.xml script on the command path of the hub agent. For more information about setting the command path of an agent, see commandPath MFT property.


librarytransfer (IBM i platform only)

The librarytransfer sample demonstrates how to use Ant tasks to transfer an IBM i library on one IBM i system to a second IBM i system.

WebSphere MQ File Transfer Edition Version 7.0.2 on IBM i does not include direct support for transfers of native IBM i library objects. The librarytransfer sample uses the native save file support on IBM i with predefined Ant tasks available in Managed File Transfer to transfer native library objects between two IBM i systems. The sample uses a <presrc> nested element in a Managed File Transfer filecopy task to invoke an executable script librarysave.sh that saves the requested library on the source agent system into a temporary save file. The save file is moved by the filecopy ant task to the destination agent system where a <postdst> nested element is used to invoke the executable script libraryrestore.sh to restore the library saved in the save file to the destination system.

Before you run this sample, we need to complete some configuration as described in the librarytransfer.xml file. We must also have a working Managed File Transfer environment on two IBM i machines. The setup must consist of a source agent running on the first IBM i machine and a destination agent running on the second IBM i machine. The two agents must be able to communicate with each other.

The librarytransfer sample consists of the following three files:

  • librarytransfer.xml
  • librarysave.sh (<presrc> executable script)
  • libraryrestore.sh (<postdst> executable script)

The sample files are located in the following directory: /QIBM/ProdData/WMQFTE/V7/samples/fteant/ibmi/librarytransfer To run this sample the user must complete the following steps:

  1. Start a Qshell session. At an IBM i command window type: STRQSH
  2. Change directory to the bin directory as follows:
    cd  /QIBM/ProdData/WMQFTE/V7/bin
  3. After completing the required configuration, run the sample by using the following command:
    fteant -f /QIBM/ProdData/WMQFTE/V7/samples/fteant/ibmi/librarytransfer/librarytransfer.xml 


physicalfiletransfer (IBM i platform only)

The physicalfiletransfer sample demonstrates how to use Ant tasks to transfer a Source Physical or Database file from a library on one IBM i system to a library on a second IBM i system.

WebSphere MQ File Transfer Edition Version 7.0.2 on IBM i does not include direct support for transfers of native Source Physical or Database files on IBM i . The physicalfiletransfer sample uses the native save file support on IBM i with predefined Ant Tasks available in Managed File Transfer to transfer complete Source Physical and Database files between two IBM i systems. The sample uses a <presrc> nested element within a Managed File Transfer filecopy task to invoke an executable script physicalfilesave.sh to save the requested Source Physical or Database file from a library on the source agent system into a temporary save file. The save file is moved by the filecopy ant task to the destination agent system where a <postdst> nested element is used to invoke the executable script physicalfilerestore.sh then restores the file object inside the save file into a specified library on the destination system.

Before you run this sample, we must complete some configuration as described in the physicalfiletransfer.xml file. We must also have a working Managed File Transfer environment on two IBM i systems. The setup must consist of a source agent running on the first IBM i system and a destination agent running on the second IBM i system. The two agents must be able to communicate with each other.

The physicalfiletransfer sample consists of the following three files:

  • physicalfiletransfer.xml
  • physicalfilesave.sh (<presrc> executable script)
  • physicalfilerestore.sh (<postdst> executable script)

The sample files are located in the following directory: /QIBM/ProdData/WMQFTE/V7/samples/fteant/ibmi/physicalfiletransfer To run this sample the user must complete the following steps:

  1. Start a Qshell session. At an IBM i command window type: STRQSH
  2. Change directory to the bin directory as follows:
    cd  /QIBM/ProdData/WMQFTE/V7/bin
  3. After completing the required configuration, run the sample by using the following command:
    fteant -f /QIBM/ProdData/WMQFTE/V7/samples/fteant/ibmi/physicalfiletransfer/physicalfiletransfer.xml 


timeout

The timeout sample demonstrates how to use Ant tasks to attempt a file transfer and to cancel the transfer if it takes longer than a specified timeout value. The script initiates a file transfer by using the Managed File Transfer fte:filecopy task. The outcome of this transfer is deferred. The script uses the Managed File Transfer fte:awaitoutcome Ant task to wait a given number of seconds for the transfer to complete. If the transfer does not complete in the given time, the Managed File Transfer fte:cancel Ant task is used to cancel the file transfer.


vsamtransfer

The vsamtransfer sample demonstrates how to use Ant tasks to transfer from a VSAM data set to another VSAM data set by using Managed File Transfer. Managed File Transfer currently does not support transferring VSAM data sets. The sample script unloads the VSAM data records to a sequential data set by using the presrc Program invocation nested elements to call the executable file datasetcopy.sh. The script uses the Managed File Transfer fte:filemove task to transfer the sequential data set from the source agent to the destination agent. The script then uses the postdst Program invocation nested elements to call the loadvsam.jcl script. This JCL script loads the transferred data set records into a destination VSAM data set. This sample uses JCL for the destination call to demonstrate this language option. The same result can also be achieved by using a second shell script instead.

This sample does not require the source and destination data sets to be VSAM. The sample works for any data sets if the source and destination data sets are of the same type.

For this sample to work correctly, we must put the datasetcopy.sh script on the command path of the source agent and the loadvsam.jcl script on the command path of the destination agent. For more information about setting the command path of an agent, see commandPath MFT property.


zip

The zip sample is made up of two scripts: zip.xml and zipfiles.xml. The sample demonstrates how to use the presrc nested element inside the Managed File Transfer fte:filemove task to run an Ant script before performing a file transfer move operation. The zipfiles.xml script called by the presrc nested element in the zip.xml script compresses the contents of a directory. The zip.xml script transfers the compressed file. This sample requires that the zipfiles.xml Ant script is present on the command path of the source agent. This is because the zipfiles.xml Ant script contains the target used to compress the contents of the directory at the source agent. For more information about setting the command path of an agent, see commandPath MFT property.

Parent topic: Use Apache Ant with MFT


Related concepts


Related reference


Related information