【发布时间】:2017-11-17 18:16:40
【问题描述】:
我正在使用带有文件名过滤器的 groovy 脚本,使用以下代码从 SFTP 位置读取文件以轮询为基础
<poll doc:name="Poll">
<schedulers:cron-scheduler expression="${payment.schedule}"/>
<scripting:transformer doc:name="Groovy">
<scripting:script engine="Groovy">
<scripting:text><![CDATA[
def endpointBuilder = muleContext.endpointFactory.getEndpointBuilder(
"sftp://${sftp.user}:${sftp.password}@${sftp.host}:${sftp.port}/${sftp.root.path}")
endpointBuilder.addMessageProcessor(new org.mule.routing.MessageFilter(new org.mule.transport.file.filters.FilenameWildcardFilter('payment_*')))
def inboundEndpoint = endpointBuilder.buildInboundEndpoint()
inboundEndpoint.request(3000L) ;
]]></scripting:text>
</scripting:script>
</scripting:transformer>
</poll>
我在这里面临的问题是,它在每个轮询时间表上只读取一个文件。 但是,我的期望是,它应该在每个轮询计划中从 SFTP 位置读取满足过滤条件的所有文件。
我怎样才能做到这一点? 谢谢。
【问题讨论】:
-
为什么不直接使用 SFTP 轮询器? docs.mulesoft.com/mule-user-guide/v/3.9/sftp-connector
-
因为它不支持过滤特定文件名的文件。这可以使用 groovy 脚本来实现。
-
是的 ;) 我会发布一个例子