【问题标题】:how to send same payload to multiple component in mule?如何将相同的有效负载发送到 mule 中的多个组件?
【发布时间】:2015-07-18 20:06:47
【问题描述】:

我有一个问题,其中一个 mule 组件将有效负载对象转换为其他值。例如:假设我的有效载荷包含学生对象。 Student name的初始值=a;

我的第一个 mule 组件将学生姓名更改为 x;

Student s=new Student();
s.setName("x");

我的第二个 mule 组件从有效负载接收名称为 X。但我希望原始值为'a'。 我尝试检查 mule 的原始有效负载,但该值也发生了变化..

<flow .....
   <component> </component> // 1st component
    <component></component> //2nd component
</flow>

我想要两个组件中的相同有效负载(原始)(名称为 a 的学生对象)..我该怎么做? 我已经检查了原始有效负载,并且已经转换了..

谢谢

【问题讨论】:

    标签: java spring mule mule-studio


    【解决方案1】:

    您可以使用&lt;all&gt; 将相同的有效负载发送到不同的组件,例如

    <flow .....
       <all>
           <component> </component> // 1st component
           <component></component> //2nd component
       </all>
    </flow>
    

    或者,处理同一件事的另一种方法是将原始有效负载存储在一个变量中,然后将有效负载替换为之前的有效负载,例如:

    <set-variable variableName="originalPayload" value="#[message.payload]" />
    

    然后,

    <set-payload value="#[flowVars.originalPayload]"/>
    

    【讨论】:

      【解决方案2】:

      Mule 还使用scatter gather 组件,它将有效负载并行发送到多个端点。该组件是从 Mule 3.5.0 引入的 .. 示例:

      <scatter-gather doc:name="Scatter-Gather" timeout="6000">
       <flow-ref name="flightBroker1" />
       <flow-ref name="flightBroker2" />
       <flow-ref name="flightBroker3" />
      </scatter-gather>
      

      这是参考:- https://developer.mulesoft.com/docs/display/current/Scatter-Gather

      【讨论】:

        猜你喜欢
        • 2013-10-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-09
        相关资源
        最近更新 更多