By Dave Berry-Oracle on Aug 10, 2015
Scriptable File Transfers are "Groovy", or Node or Python, batch files or plain ole boring Bourne shell scripts invoked by the MFT runtime server. Maybe you want to maintain a library of custom callouts, java code or manage moving them from one environment to another? No problem, use the Ginzu knife of callouts to extend MFT, the Run Script Pre-Processing callout now available on the MFT OTN page at bit.ly/learnmft. This baby can do it all, file processing, add new endpoints, enable REST, notify or validate. Got your attention, read on for more details or if you're already sold, just click the link to download and open the README file.
Use CasesI hate repeating myself but there is virtually no limit to what can be done with this tool but before we blogstorm on this topic, lets briefly review MFT Java callouts from previous blog entries and the official Oracle MFT 12.1.3 documentation. To create a callout from scratch, you have these 6 basics steps.
- Create code
- Create XML defintiion
- Copy jar to disk
Not really that painful for the DIY types but to use RunScript, you can skip the 1st 3 and just do import, copy and test.
- Import Sample Transfer
- Copy the jar (as described in the readme)
- Test basic scenarios
Internal Processing Things Callouts Can Do
- Rename and Replace file with different file
- Reject a file and return an error
- Update the monitoring dashboard transfer report
- protocol headers section
- Duplicate the file elsewhere
Source pre-processing is triggered right after a file has been received and has identified a matching Transfer. This is the best place to do validation or extend MFT to go grab a file from some external source. There is an FTPGet.sh example in the RunScript download that shows how to do custom FTP commands such a SITE often needed when interacting with mainframes.
Target pre-processing triggered just before the file is delivered to the Target by the Transfer. This is a good place to send files to external locations and protocols not supported in MFT. RunScript supports retry semantics and if an error is received, it is reflected in the MFT monitoring dashboard where it can be diagnosed or resubmitted.
RunScriptPre can not be invoked for Target Post processing. A separate callout would be required for that. Post Target processing is not suited for file manipulation and is best for notifications, analytic/reporting or maybe remote endpoint file rename.
Once imported and available in the designer, the callout UI supports the following parameters.
- ScriptLocation: disk location of script. Ex: test.sh etc...
- Parameters: custom parameters to send to the script. Ex: remotehost=jokes.huli.org
- UseFileFromScript: CheckBox; TRUE or FALSE. When checked, it will use the file returned from the script.
- RetryCount: Number of retries in cases of failure
- RetryInterval: number of seconds to wait between retries
The following parameters are not enabled in the UI and always sent to the script.
- targetname (not for source callouts)
The following sample scripts are provided in the RunScriptPre zip file.
- test.sh: This shows how to parse the parameters shown above and the use of UseFileFromScript to generate and replace the original file with a tar file.
- compress.sh: This is a functional script to replace the original file with either a tar or gzip file. It takes the parameter "compress=tar | gzip"
- FTPGet.sh: as mentioned above, this should how to do custom FTP commands
That pretty much it, there are lots of use cases this tool can solve without having to write a single line of java code. The big win is scripts now can be integrated into the MFT designer and run-time monitoring dashboards. Roll up your sleeves, go explore and report back on other creative ways to extend MFT using this handy utility.