Sample Ant tasks
There are a number of sample Ant scripts provided with
your installation of IBM® MQ 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.
hub
The hub sample is made up of two scripts: hubcopy.xml and hubprocess.xml. The hubcopy.xml script shows how you 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, you 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.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.
IBM MQ Managed File Transfer V7.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 IBM MQ Managed File Transfer to transfer native library objects between two IBM i systems. The sample uses a <presrc> nested element in a IBM MQ 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, you need to complete some configuration as described in the librarytransfer.xml file. You must also have a working IBM MQ 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.
- librarytransfer.xml
- librarysave.sh (<presrc> executable script)
- libraryrestore.sh (<postdst> executable script)
- Start a Qshell session. At an IBM i command window type:
STRQSH
- Change directory to the bin directory as
follows:
cd /QIBM/ProdData/WMQFTE/V7/bin
- 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.IBM MQ Managed File Transfer V7.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 IBM MQ 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 IBM MQ 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, you must complete some configuration as described in the physicalfiletransfer.xml file. You must also have a working IBM MQ 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.
- physicalfiletransfer.xml
- physicalfilesave.sh (<presrc> executable script)
- physicalfilerestore.sh (<postdst> executable script)
- Start a Qshell session. At an IBM i command window type:
STRQSH
- Change directory to the bin directory as
follows:
cd /QIBM/ProdData/WMQFTE/V7/bin
- 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 IBM MQ Managed File Transfer filecopy task. The outcome of this transfer is deferred. The script uses the IBM MQ Managed File Transfer fte:awaitoutcome task to wait a given number of seconds for the transfer to complete. If the transfer does not complete in the given time, the IBM MQ Managed File Transfer fte:cancel 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 IBM MQ Managed File Transfer. IBM MQ 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
nested element to call the executable
file datasetcopy.sh. The script uses the IBM MQ 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
nested element 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, you 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.
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 IBM MQ 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.