2012-10-12 54 views
1

編輯:簡化的問題。Mule ESB 3.3「全部」流量混亂了下游組件的有效載荷

爲什麼地球上寫入的文件是垃圾(二進制serilized數據)而不是在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> 

回答

2

這是非常棘手的:所述all消息處理器改變飛行騾消息從一個MuleMessage的性質到MuleMessageCollection 。更改MuleMessageCollection上的有效載荷基本上無效。

您需要用新的MuleMessage強制替換當前的MuleMessageCollection。爲您的最後一個Groovy組件使用以下代碼:

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