简体   繁体   English

如何将相同的有效载荷发送到m子中的多个组件?

[英]how to send same payload to multiple component in mule?

I have a problem where one mule component transform the payload object into some other value. 我有一个问题,其中一个m子组件将有效载荷对象转换为其他值。 Ex: Suppose my payload contain student object. 例如:假设我的有效载荷包含学生对象。 Initial value of Student name=a; 学生姓名的初始值= a;

My first mule component change student name to x; 我的第一个m子组件将学生姓名更改为x;

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

My second mule component receive name as X from payload. 我的第二个ule子组件从有效载荷中接收到名称X But I want original value as 'a' . 但是我想要原始值为'a' I tried checking original payload of mule but that value is also changed.. 我尝试检查original子的原始有效载荷,但该值也已更改。

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

I want same payload(original) (Student object with name a) in both the component..how can I do that? 我在两个组件中都希望使用相同的有效载荷(原始)(名称为a的学生对象)。该怎么办? I have checked original payload and that has been transformed.. 我已经检查了原始有效载荷,并且已经转换了。

Thanks 谢谢

You can use <all> to send same payload to different components like 您可以使用<all>将相同的有效载荷发送到不同的组件,例如

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

or, a different way to approach same thing is to store the original payload in a variable and then replace the payload with the previous one like: 或者,处理同一件事的另一种方法是将原始有效负载存储在变量中,然后将有效负载替换为之前的有效负载,例如:

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

and then, 接着,

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

Mule also use scatter gather component, which sends the payload to multiple endpoints in parallel. Mule还使用scatter gather组件,该组件将有效负载并行发送到多个端点。 This component has been introduced from Mule 3.5.0 .. example : 此组件是从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>

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM