Search code examples
ibm-mqfile-transferwebsphere-mq-fte

Is it possible to have a list of files transferred after a successful transfer in WMQ-FTE?


I would like to move some files to a time-stamped directory after I transfer them using WMQ-FTE. I am running v7.0.4.1.

My problem is that there are always new files being written to the directory I am transferring out of, so just blindly transferring everything is not the way. I also batch up the transfer triggers as they happen in batches of about 1000, so only one transfer occurs per 1000 files to be transferred.

I was hoping there would be some metadata that contained a list of the paths of the files transferred so I could move them to a directory before or after the transfer happens. The directory creation would be part of a pre or post source call.


Solution

  • Take a look at the DestinationTransferEndExit.java API documentation. In particular, look at the fileResults parameter. An ANT task can use this parameter to perform actions on specific files.

    /**
     * Invoked immediately after the completion of a transfer on the agent acting as
     * the destination of the transfer.
     * 
     * @param transferExitResult
     *            a result object reflecting whether or not the transfer completed
     *            successfully.
     * 
     * @param sourceAgentName
     *            the name of the agent acting as the source of the transfer.
     * 
     * @param destinationAgentName
     *            the name of the agent acting as the destination of the
     *            transfer.  This is the name of the agent that the 
     *            implementation of this method will be invoked from.
     * 
     * @param environmentMetaData
     *            meta data about the environment in which the implementation
     *            of this method is running.  This information can only be read,
     *            it cannot be updated by the implementation.  The constants
     *            defined in <code>EnvironmentMetaDataConstants</code> class can 
     *            be used to access the data held by this map.
     * 
     * @param transferMetaData
     *            meta data to associate with the transfer.  The information can
     *            only be read, it cannot be updated by the implementation.  This 
     *            map may also contain keys with IBM reserved names.  These 
     *            entries are defined in the <code>TransferMetaDataConstants</code> 
     *            class and have special semantics.
     * 
     * @param fileResults
     *            a list of file transfer result objects that describe the source
     *            file name, destination file name and result of each file transfer
     *            operation attempted.
     * 
     * @return    an optional description to enter into the log message describing
     *            transfer completion.  A value of <code>null</code> can be used
     *            when no description is required.
     */
    String onDestinationTransferEnd(TransferExitResult transferExitResult,
                    String sourceAgentName,
                    String destinationAgentName,
                    Map<String, String>environmentMetaData,
                    Map<String, String>transferMetaData, 
                    List<FileTransferResult>fileResults);