SFTP Enqueue_Dequeue

Enqueue

Enqueueing from SFTP is quite similar to File Enqueue except that the MessageSource is defined differently. To connect to SFTP, we need parameters like Host, Port, Username, Password. For example:

<MessageSource>
<ValueChainId>9123</ValueChainId>
<Name>FileInbox</Name>
<SourceType>SFTP</SourceType>
<Config>{ host: 'mysftp.com', port: 22, Username: 'foo', Password: 'bar', polledDir: '/my/polleddir', sftpLib:'jsch' }</Config>
</MessageSource>

Dequeue

Dequeuing to SFTP is quite similar to Dequeue to file except for the MessageDestination specification.

A MessageDestination of DestinationType SFTP is used to configure the final destination for a message being dequeued to SFTP. To connect to SFTP, we need parameters like Host, Port, Username, Password. For example:

<MessageDestination>
<ValueChainId>9123</ValueChainId>
<Name>LocalSFTP</Name>
<DestinationType>SFTP</DestinationType>
<Config>{host: '127.0.0.1', port: 22, Username: 'username', Password: 'password', fileNamePattern: '/one/PLT/%{FileName}', sftpLib:'jsch'</Config>
</MessageDestination>
    
The Config is a JSON object containing:    
  • host (required) – IP Address of the SFTP m/c.

  • port (required) – Port number to connect to SFTP m/c.

  • Username (required) – Username of the SFTP m/c to connect.

  • Password (required) – Password of the SFTP m/c to connect.

  • fileNamePattern (optional) – fileNamePattern is an optional file name substitution pattern used when dequeuing messages along with remote location in the SFTP m/c i.e. /one/PLT/%{fileName}.csv. If location is provided then the file will be streamed to that remote location. If not provided, the file will be streamed to the user’s home directory.

  • fileNamer (optional) - as an alternative to fileNamePattern, you can provide a fileNamer. Here you should give a groovy expression that evaluates the desired value of the file name. The com.onenetwork.platform.integ.msg.Message being dequeued will be bound under the name msg so you can use things like interface name, client file name, etc. to help you generate the final file name.

    Example:

    fileNamer: 'msg.getOutboundInterface() + "." + System.currentTimeMillis() + ".csv"'

    or

    fileNamer: 'if ("ZBKS.BookLoad".equals(msg.getOutboundInterface())) { msg.getOutboundInterface() + "." + System.currentTimeMillis() + ".csv" } else { resolvedFileName }'

  • tempFileNamePattern (optional) – Same as of fileNamePattern except if provided, file will be first streamed to temp remote location and the moved to the location specified in fileNamePattern.

  • sftpLib (optional) – Optional param to configure ssh library to use. j2ssh is legacy and jsch is the new library.