View Only

IBM MQ MFT: Customizing transfers using transfer exits

By Shashikanth Rao Thambrahalli posted Sat June 18, 2022 12:44 PM


IBM MQ Managed File Transfer (MFT) transfers files between systems in a managed and auditable way, regardless of file size or the operating systems used. You can use Managed File Transfer to build a customized, scalable, and automated solution that enables you to manage, trust, and secure file transfers. Managed File Transfer eliminates costly redundancies, lowers maintenance costs, and maximizes your existing IT investments.

Using resource monitors you can configure an MFT agent to automatically initiate transfers when an event occurs. With filters, known as “match” conditions, you can further customize transfer definitions. For example:

  • Transfer only those files that have an extension of “.doc” or “.pdf”.
  • Transfer files whose size is equal to or greater than certain value, say 5KB.
  • Transfer only those files whose size did not change in specified number of monitor polls.

As seen #2 above – resource monitor can be configured to initiate transfer of files whose size is equal to or greater than certain value. Now what if the requirement is to transfer only those files whose size is in between, say 2KB and 10 KB (or any specified value)?

MFT provides interfaces to customize transfers through a concept called “exits”. These exits must be written in Java and implement certain interfaces defined by MFT. The code in the exits is run before a transfer begins and completes at source and destination agents. There are four types of interfaces provided by MFT –

  • SourceTransferStartExit - Before the entire file transfer starts
  • DestinationTransferStartExit - Before the entire file transfer starts
  • DestinatonTransferEndExit - After the entire file transfer is complete
  • SourceTransferEndExit - After the entire file transfer is complete

More details on the exits are here -

For our requirement here, i.e., transfer only those files whose size is in between the specified range, a SourceTransferStartExit can be used. The source agent calls the exit with a modifiable list of files to transfer. The exit code can then:

  • Iterate through the list of files.
  • Keep the filename in the list if its size lies in the specified range.
  • Remove the filenames from the list whose size is out of the specified range.
  • Return the modified list of files back to agent to transfer files.

Here is a sample exit that performs the above actions to filter files of specified sizes. The sample also contains instructions on how to compile and deploy the exit. The sample reads an XML file to determine the minimum and maximum file sizes. The sample can be easily modified to pass file size limits as metadata with the transfer request itself.

You must note that the exit gets called for every transfer request submitted to an agent. You can however control whether the code in the exit is executed completely or not. You can pass metadata, a key-value pairs of data with the transfer request for this purpose. For example., you can specify “FILTER”=”YES” with the transfer request. At the beginning of the entry point of the exit, a check for “FILTER”== “YES” can be made. If the condition satisfies, then rest of the code in the exit is executed. If the “FILTER” key is not specified or the value is set to something else, the exit can simply return without doing anything further.