我的mule配置文件包含以下流程:
<flow name="HTTP input1">
<ftp:inbound-endpoint user="username" password="secret" host="host" path="location" port="21">
<file:filename-wildcard-filter pattern="." />
</ftp:inbound-endpoint>
<file:outbound-endpoint path="E:/Mule/Inbound" outputPattern="#[header:originalFilename]" >
</file:outbound-endpoint>
</flow>
我能够移动文件,但我需要的是读出文件内容并根据该内容将其放在特定目录中。
例如,如果我的文件内容有“Vendor1”,那么它应该将文件放在Vendor1下。仅供参考:Vendor1不是静态的。它可能是Vendor1000。关于这个的任何想法?
答案 0 :(得分:1)
您想要做的是:
类似的东西:
<flow name="HTTP input1">
<ftp:inbound-endpoint user="username"
password="secret"
host="host"
path="location"
port="21">
<file:filename-wildcard-filter pattern="." />
</ftp:inbound-endpoint>
<script:transformer name="stringReplaceWithParams">
<script:script engine="groovy">
<script:text>
// here the payload variable should contain a byte[] from the remote FTP file
// ... munch-munch the byte[] with Groovy to find the value to put in targetSubDir
var targetSubDir = ...
message.setOuboundProperty('targetSubDir', targetSubDir)
// return the payload unchanged, we just changed a message property
return payload
</script:text>
</script:script>
</script:transformer>
<file:outbound-endpoint path="E:/Mule/Inbound/#[header:targetSubDir]"
outputPattern="#[header:originalFilename]" />
</flow>