Rajesh
Rajesh

Reputation: 3034

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. Ex: Suppose my payload contain student object. Initial value of Student name=a;

My first mule component change student name to x;

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

My second mule component receive name as X from payload. But I want original value as 'a'. I tried checking original payload of mule but that value is also changed..

<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? I have checked original payload and that has been transformed..

Thanks

Upvotes: 1

Views: 2450

Answers (2)

Anirban Sen Chowdhary
Anirban Sen Chowdhary

Reputation: 8321

Mule also use scatter gather component, which sends the payload to multiple endpoints in parallel. This component has been introduced from Mule 3.5.0 .. example :

<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

Upvotes: 3

Charu Khurana
Charu Khurana

Reputation: 4551

You can use <all> to send same payload to different components like

<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]"/>

Upvotes: 4

Related Questions