【发布时间】:2021-05-30 04:23:13
【问题描述】:
我是 Mule 的新手。我必须完成以下任务。
文件位于某个位置。我需要将该文件移动到其他位置。选择位置的标准基于文件名。
假设,文件名为'abc_loc1'。然后将该文件移动到文件夹 Location1 中。如果文件名为'abc_loc2',则应将其移至Location2。
【问题讨论】:
标签: file mule mule-studio
我是 Mule 的新手。我必须完成以下任务。
文件位于某个位置。我需要将该文件移动到其他位置。选择位置的标准基于文件名。
假设,文件名为'abc_loc1'。然后将该文件移动到文件夹 Location1 中。如果文件名为'abc_loc2',则应将其移至Location2。
【问题讨论】:
标签: file mule mule-studio
您可以将 Mule file transport 与入站和出站端点一起使用来移动文件,并为出站设置动态路径属性,或根据原始文件名使用 choice routing。您将获得作为 #[message.inboundProperties.originalFilename] 的原始文件名。
更新(示例流程):
<file:connector name="File"/>
<flow name="exampleFlow">
<file:inbound-endpoint connector-ref="File" path="/tmp/1" responseTimeout="10000" />
<set-variable variableName="myPath" value="#[message.inboundProperties['originalFilename'].substring(message.inboundProperties['originalFilename'].indexOf('_')+1)]" />
<file:outbound-endpoint path="/tmp/#[flowVars['myPath']]" responseTimeout="10000" connector-ref="File" outputPattern="error#[message.inboundProperties['originalFilename']]"/>
</flow>
更新 2:
要使用选择路由,将上述文件出站替换为以下内容:
<choice>
<when expression="#[flowVars['myPath'] == '1']">
<file:outbound-endpoint path="/tmp/1" responseTimeout="10000" connector-ref="File" outputPattern="error#[message.inboundProperties['originalFilename']]"/>
</when>
<when expression="#[flowVars['myPath'] == '2']">
<file:outbound-endpoint path="/tmp/2" responseTimeout="10000" connector-ref="File" outputPattern="error#[message.inboundProperties['originalFilename']]"/>
</when>
</choice>
【讨论】: