在Mule并行运行流

在Mule并行运行流

本文介绍了在Mule并行运行流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mule中有两个要并行运行的流.第一个流程应使用sftp将文件从远程计算机传输到本地目录(只要在远程目录中不断更新文件,此操作就不会停止).第二个流程必须通过调用Pentaho水壶转换/作业将文件中的数据更新/插入到数据库中(只要文件不断进入,它也是连续过程).但是,当我运行我的流程时,它以某种方式通过了第一个流程,并且仅尝试执行第二个流程.我怎样才能解决这个问题?这是我的M子流:

I have two flows in Mule that i want to run in parallel. The first flow should transfer a file from a remote machine using sftp to a local directory (does this none stop as long as the file is constantly updated in the remote directory). The second flow must take the data in the file at update/insert them into the database by invoking a Pentaho kettle transformation/job (also continuous process as long as the files keep coming in). However, when i run my flow, it is somehow by passing the first flow and only tries to perform the second flow. How can i fix this? Here is my Mule FLow:

<flow name="flow1">
  <sftp:inbound-endpoint
    address="sftp://username:password@ip_ddress:22/path"
    responseTimeout="1000" />
  <echo-component />
  <file:outbound-endpoint path="/path/to/OutputFolder"
    responseTimeout="10000"/>
</flow>

<flow name="flow2">
  <custom-transformer class="org.transformation.kettle.InvokeMain" />
</flow>

推荐答案

第二个流应具有file:outbound-endpoint来拾取第一个流丢弃的文件:

Your second flow should have a file:outbound-endpoint to pick up the file dropped by the first flow:

<flow name="flow1">
  <sftp:inbound-endpoint
      address="sftp://username:password@ip_ddress:22/path"
      responseTimeout="1000" />
  <logger level="INFO"
      message="#[message.payloadAs(java.lang.String)]" />
  <file:outbound-endpoint path="/path/to/OutputFolder" />
</flow>

<flow name="flow2">
  <file:inbound-endpoint path="/path/to/OutputFolder"
      fileAge="10000" />
  <custom-transformer class="org.transformation.kettle.InvokeMain" />
</flow>

请注意,我已经

  • 将超旧的<echo-component />替换为更现代的logger.我记录了消息有效负载,我认为这是您的意图?
  • file:outbound-endpoint删除无用的responseTimeout="10000"
  • 在入站文件端点上将fileAge设置为10秒,以防止拾取仍由SFTP入站端点写入的文件.如果太大或太小,请调整值.
  • Replaced the super old <echo-component /> with the more modern logger. I log the message payload, which I think was your intention?
  • Dropped the useless responseTimeout="10000" from the file:outbound-endpoint,
  • Set a fileAge of 10 seconds on the inbound file endpoint to prevent picking up a file that is still written by the SFTP inbound endpoint. Tune the value if too big or small.

这篇关于在Mule并行运行流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 23:37