Customizing MFT with user exits

You can customize the features of Managed File Transfer by using your own programs known as user exit routines.

Managed File Transfer provides points in the code where Managed File Transfer can pass control to a program that you have written (a user exit routine). These points are known as user exit points. Managed File Transfer can then resume control when your program has finished its work. You do not have to use any of the user exits, but they are useful if you want to extend and customize the function of your Managed File Transfer system to meet your specific requirements.

There are two points during file transfer processing where you can invoke a user exit at the source system and two points during file transfer processing where you can invoke a user exit at the destination system. The following table summarizes each of these user exit points and the Java interface that you must implement to use the exit points.
Table 1. Summary of source-side and destination-side exit points and Java interfaces
Exit point Java interface to implement
Source-side exit points:
Before the entire file transfer starts SourceTransferStartExit.java interface
After the entire file transfer is complete SourceTransferEndExit.java interface
Destination-side exit points:
Before the entire file transfer starts DestinationTransferStartExit.java interface
After the entire file transfer is complete DestinationTransferEndExit.java interface
The user exits are invoked in the following order:
  1. SourceTransferStartExit
  2. DestinationTransferStartExit
  3. DestinationTransferEndExit
  4. SourceTransferEndExit
Changes made by the SourceTransferStartExit and DestinationTransferStartExit exits are propagated as input to subsequent exits. For example if the SourceTransferStartExit exit modifies the transfer metadata, the changes are reflected in the input transfer metadata to the other exits.
User exits and program calls are invoked in the following order:

- SourceTransferStartExit(onSourceTransferStart).
- PRE_SOURCE Command.
- DestinationTransferStartExits(onDestinationTransferStart).
- PRE_DESTINATION Command.
- The Transfer request is performed.
- DestinationTransferEndExits(onDestinationTransferENd).
- POST_DESTINATION Command.
- SourceTransferEndExits(onSourceTransferEnd.
- POST_SOURCE Command.
Notes:
  1. The DestinationTransferEndExits is run only when the transfer completes, either successfully or partially successfully.
  2. The postDestinationCall is run only when the transfer completes, either successfully or partially successfully.
  3. The SourceTransferEndExits is run for successful, partially successful, or failed transfers.
  4. The postSourceCall is called only if:
    • The transfer was not canceled.
    • There is a successful or partially successful outcome.
    • Any post-destination transfer programs ran successfully.

Building your user exit

The interfaces to build a user exit are contained in MQ_INSTALL_DIRECTORY/mqft/lib/com.ibm.wmqfte.exitroutines.api.jar. You must include this .jar file in the class path when you build your exit. To run the exit, extract the exit as a .jar file and place this .jar file in a directory as described in the following section.

User exit locations

You can store your user exit routines in two possible locations:
  • The exits directory. There is an exits directory under each agent directory. For example: var\mqm\mqft\config\QM_JUPITER\agents\AGENT1\exits
  • You can set the exitClassPath property to specify an alternative location. If there are exit classes in both the exits directory and the class path set by exitClassPath, the classes in the exits directory take priority, which means that if there are classes in both locations with the same name, the classes in the exits directory take priority.

Configuring an agent to use user exits

There are four agent properties that can be set to specify the user exits that an agent invokes. These agent properties are sourceTransferStartExitClasses, sourceTransferEndExitClasses, destinationTransferStartExitClasses, and destinationTransferEndExitClasses. For information about how to use these properties, see MFT Agent properties for user exits.

Running user exits on protocol bridge agents

When the source agent invokes the exit, it passes the exit a list of the source items for the transfer. For normal agents, this is a list of fully-qualified filenames. Because the files should be local (or accessible via a mount), then the exit is able to access it and encrypt it.

However, for a Protocol Bridge Agent, the entries in the list are of the following format:
"<file server identifier>:<fully-qualified file name of the file on the remote file server>"

For each entry in the list, the exit needs to connect to the file server first (using either the FTP. FTPS or SFTP protocols), download the file, encrypt it locally and then upload the encrypted file back to the file server.

Running user exits on Connect:Direct bridge agents

You cannot run user exits on Connect:Direct® bridge agents.