骡子表达块不起作用?

时间:2015-03-03 22:25:44

标签: mule mule-studio

以下是我的流程。

enter image description here

在“表情”设置中,我只有以下内容:

key != 0

文件连接器的文件名/模式为#[key]

它仍然输出一个名为0的文件,其中包含电子邮件正文。它还会正确输出所有其他附件。我只是不希望它将电子邮件正文写入文件。我做错了什么?

完整代码:

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns="http://www.mulesoft.org/schema/mule/core"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:spring="http://www.springframework.org/schema/beans"
       xmlns:imap="http://www.mulesoft.org/schema/mule/imap"
       xmlns:vm="http://www.mulesoft.org/schema/mule/vm"
       xmlns:file="http://www.mulesoft.org/schema/mule/file"
       xmlns:email="http://www.mulesoft.org/schema/mule/email"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.6/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.6/mule-file.xsd
http://www.mulesoft.org/schema/mule/imap http://www.mulesoft.org/schema/mule/imap/3.6/mule-imap.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/3.6/mule-email.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/3.6/mule-vm.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd" version="EE-3.6.0">

    <imap:connector name="imapConnector" checkFrequency="10000" doc:name="IMAP" /> 

    <expression-transformer name="returnAttachments" doc:name="Expression">
        <return-argument evaluator="attachments-list" expression="*"/>
    </expression-transformer>

    <file:connector name="fileName" doc:name="File"> 
        <file:expression-filename-parser/> 
    </file:connector>
    <flow name="incoming-orders">
        <imap:inbound-endpoint host="server" port="143" user="user" password="pass" disableTransportTransformer="true" transformer-refs="returnAttachments" doc:name="IMAP"/>
        <foreach doc:name="For Each" collection="#[message.inboundAttachments]" counterVariableName="i" rootMessageVariableName="msg">
            <expression-component doc:name="Expression">key != 0</expression-component>
            <file:outbound-endpoint path="c:\Mule\in" outputPattern="#[key]" doc:name="File" responseTimeout="10000">
                <expression-transformer> 
                    <return-argument expression="payload.inputStream" evaluator="groovy"/> 
                </expression-transformer>
            </file:outbound-endpoint>
        </foreach>
    </flow>
</mule>

1 个答案:

答案 0 :(得分:1)

看起来foreach正在处理inboundAttachments地图的,因此您无法获取密钥。我建议像:

<foreach doc:name="For Each" collection="#[message.inboundAttachments.entrySet()]"> <expression-transformer doc:name="Expression" expression="#[payload.key != 0]"/> ... </foreach>

现在您将处理键值对,因此您可能需要使用set-payload仅发送payload.value,然后将该键保存在要在文件端点中使用的变量中。