Search code examples
ftpmuleesbzos

Is it possible to send an FTP SITE command through a Mule FTP connector?


I have business with a recipient FTP site that requires me to send a sequence of SITE commands before initiating any transfer (presumably because the receiving server is an old mainframe that assumes any connecting client is also a zOS or zVM system and this seems to be a default between them) and we are using Mule ESB Community to connect to this server. Does anyone know if this is possible using the standard FTP connector?

Sample sequence:

site FIXRECFM 80 LRECL=80 RECFM=FB WRAPRECORD

Solution

  • The key is that Mule's underlying FTP client uses org.apache.commons.net.ftp.FTPClient, and this object supports a sendSiteCommand() method that lets you send arbitrary SITE commands. All you need to do is hunt down the FTPClient, which I believe you can do by calling getFTP() on Mule's FTPConnector.

    If you only need the SITE commands once as the connection is issued, then you can also create a custom Mule FTP connection factory. This lets you insert a small bit of extra logic to send your "SITE" commands using the sendSiteCommand() method whenever Mule initializes the FTP connection. The benefit is that you get the right behavior automatically just by switching to the custom FTP connection factory - no special logic is needed within the app.