How to use mule requester for SFTP - Dynamic file name and path

拜拜、爱过 提交于 2019-12-04 15:32:24

The Mule SFTP connector can not take the filename in the address. Instead you need to use a filename filter. However, unfortunately I think the requestor module ignores the filters configured on the endpoint as mentioned here: http://forum.mulesoft.org/mulesoft/topics/mule_module_requester_add_support_for_filenamefilter

You could however use a script to read a file over sftp mid flow. Something like:

<scripting:transformer>
            <scripting:script engine="Groovy">
                <scripting:text>
                    def endpointBuilder = muleContext.endpointFactory.getEndpointBuilder( 
                    "sftp://${sftp.username}@${sftp.host}:${sftp.port}/${sftp.path}?identityFile=${app.home}/${sftp.keyPath}&amp;passphrase=${sftp.passphrase}&amp;connector=sftp-csv") 
                    endpointBuilder.addMessageProcessor(new org.mule.routing.MessageFilter(new org.mule.transport.file.filters.FilenameWildcardFilter(sessionVars.expectedFilename))) 
                    def inboundEndpoint = endpointBuilder.buildInboundEndpoint() 
                    inboundEndpoint.request(30000L) 
                </scripting:text>
            </scripting:script>
        </scripting:transformer>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!