【问题标题】:Moving file from one location to another in Mule在 Mule 中将文件从一个位置移动到另一个位置
【发布时间】:2021-05-30 04:23:13
【问题描述】:

我是 Mule 的新手。我必须完成以下任务。

文件位于某个位置。我需要将该文件移动到其他位置。选择位置的标准基于文件名。

假设,文件名为'abc_loc1'。然后将该文件移动到文件夹 Location1 中。如果文件名为'abc_loc2',则应将其移至Location2

【问题讨论】:

    标签: file mule mule-studio


    【解决方案1】:

    您可以将 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>
    

    【讨论】:

    • 能否分享配置xml文件
    • 添加了一个与您的描述大致对应的简单示例。
    • 谢谢 Anton,实际上我的文件名不包含位置,它只提示文件应该放在哪个位置。例如,如果文件名是 abc_loc1,则 loc1 不是实际文件夹,它只是位置的标识符。就像 loc1 可以告诉我文件夹位置是'/tmp/data'等
    • 再次使用选择路由选项更新了我的帖子
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-13
    相关资源
    最近更新 更多