2014-03-03 140 views
0

我是Mule的新手。我必须执行以下任务将文件从一个位置移动到另一个位置在Mule

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

假设文件名是'abc_loc1'。然后这个文件将被移动到文件夹位置1。如果文件名是'abc_loc2',则应将其移入位置2

任何帮助将不胜感激。

回答

1

您可以使用带入站和出站端点的Mule file transport来移动文件,并为出站设置动态路径属性,或使用基于原始文件名的choice routing。您将具有#[message.inboundProperties.originalFilename]的原始文件名称。

UPDATE(例如流):

<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> 
+0

可以请你分享配置xml文件 – Anand

+0

添加了一个与您的描述大致相对应的简单示例。 –

+0

感谢Anton,实际上我的文件名不包含位置,它只提示文件应该放置哪个位置。例如,如果文件名是abc_loc1,loc1不是实际的文件夹,它只是位置的标识符。像loc1可以告诉我,文件夹位置是'/ tmp/data'等 – Anand

相关问题