Mule ESB 3.3“全部”流量会影响下游组件的有效负载

时间:2012-10-12 00:24:07

标签: esb mule synchronous payload

编辑:简化问题。

为什么在地球上,写入的文件是垃圾(二进制服务数据)而不是Groovy组件中设置的有效负载?只有存在“全部”流组件时才会发生这种情况。

流速:

enter image description here

XML:

<file:connector name="OutputFile" autoDelete="true" streaming="true" validateConnections="true" doc:name="File" writeToDirectory="#{systemProperties['user.home']}"/>
<flow name="AllProblemFlow1" doc:name="AllProblemFlow1">
    <vm:inbound-endpoint exchange-pattern="one-way" path="in" doc:name="VM"/>
    <all doc:name="All">
        <processor-chain>
            <scripting:component doc:name="Groovy">
                <scripting:script engine="Groovy">
                    <scripting:text><![CDATA[return payload + 1]]></scripting:text>
                </scripting:script>
            </scripting:component>
        </processor-chain>
        <processor-chain>
            <scripting:component doc:name="Groovy">
                <scripting:script engine="Groovy">
                    <scripting:text><![CDATA[return payload + 2]]></scripting:text>
                </scripting:script>
            </scripting:component>
        </processor-chain>
    </all>
    <logger message="All payload: #[payload]" level="INFO" doc:name="Logger"/>
    <scripting:component doc:name="Groovy">
        <scripting:script engine="Groovy">
            <scripting:text><![CDATA[return "new payload"]]></scripting:text>
        </scripting:script>
    </scripting:component>
    <file:outbound-endpoint responseTimeout="10000" connector-ref="OutputFile" doc:name="File" outputPattern="output.txt" path="#{systemProperties['user.home']}"/>
</flow>

1 个答案:

答案 0 :(得分:2)

这非常棘手:all消息处理器将正在进行的Mule消息的性质从MuleMessage更改为MuleMessageCollection。更改MuleMessageCollection上的有效负载基本上无效。

您需要用全新的MuleMessageCollection强制替换当前的MuleMessage。将以下代码用于上一个Groovy组件:

<scripting:text><![CDATA[
    return new org.mule.DefaultMuleMessage("new payload", muleContext)
]]></scripting:text>