繁体   English   中英

写入文件后如何在m子流中使用sftp?

[英]How to use sftp in the mule flow after writing a file?

我有一个业务流程,该流程调用一个子流来写入文件,然后再下一个流(通过流ref)来sftp。

WriteSubflow

 <file:outbound-endpoint path="${outputDir}" outputPattern="${fileName}" responseTimeout="10000" doc:name="Write file"/>

 <logger message="File ${fileName}  written to ${outputDir}" level="INFO" doc:name="End"/>

然后,我调用一个流(通过ref)启动sftp进程。

<flow name="sftp">
    <file:inbound-endpoint path="${outputDir}" connector-ref="File" responseTimeout="10000" doc:name="File">
        <file:filename-regex-filter pattern="${fileName}" caseSensitive="true"/>
    </file:inbound-endpoint>
    <sftp:outbound-endpoint exchange-pattern="one-way" connector-ref="SFTP"  responseTimeout="10000" ref="endpoint" doc:name="SFTP"  />
</flow>

问题是

  1. 在写入文件的过程中,该流程在文件出站终结点之后执行记录器,并说文件已经写入,并且在一段时间之后,文件连接器吐出“ Write file to ...”。 如何使记录仪等待文件写入完成?

  2. 上面的流sftp中的文件入站端点被立即执行,文件还没有准备好。 因此它引发异常,首先要说它期望一个InputStream或byte []或String,但是得到一个ArrayList(这是业务流程中的原始有效负载)。 打印此异常后,最终文件已准备就绪,入站文件连接器启动,对其进行读取并对其进行sftps处理。 这似乎与上述问题有关,在这里我需要以某种方式使其余流程等待文件写入完成。

注意:我必须将sftp流创建为流而不是子流,因为它需要作为源。 我认为,如果我不创建它的流,并且没有文件连接器作为源,它将成为出站连接器。

任何帮助表示赞赏。

所以我终于弄清楚了,这两个问题都在这里的一篇博客文章中得到了解答:http://www.sixtree.com.au/articles/2015/advanced-file-handling-in-mule/

#1的关键是

 <file:connector name="synchronous-file-connector" doc:name="File">
     <dispatcher-threading-profile doThreading="false"/>
</file:connector>

对于Ryan提到的#2,使用m子请求程序模块。

1)设置流量的procesingStrategysynchronous

<flow name="testFlow" processingStrategy="synchronous">
        <poll frequency="10000">
            <set-payload value="some test text" />
        </poll>

        <file:outbound-endpoint path="/Users/ryancarter/Downloads"
            outputPattern="test.txt" />

        <logger level="ERROR" message="After file..." />
</flow>

2)不确定我是否很了解,但是您不能通过flow-ref调用入站端点,因此无论调用流如何,入站端点都将被忽略,入站端点将自己运行。 如果您想在文件流中读取文件,请使用mule-requestor模块: http : //blogs.mulesoft.com/introducing-the-mule-requester-module/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM