Question

I have a foreach element in my flow, which has a variable named "counter" set. Inside the foreach, I have a component, and I'm trying to get access to the "counter" variable from within the component. What is the proper way to get a hold of this variable from inside the component? Does it require adding a parameter to the method? I already have a parameter to take in the payload.

Était-ce utile?

La solution

Any variable from the mule flow can be accessed inside a Component by using the

muleMessage.getInvocationProperty("counter");

muleMessage can be obtained from MuleEventContext of the onCall(MuleEventContext arg0) method. Assuming that you have implemented Callable interface of mule.

If not, try getting the message from org.mule.RequestContext.getEvent().getMessage() This is RequestContext is deprecated as of now.

Hope this helps.

Autres conseils

If we set the counter value in a property, we can get that property in inbound properties of message inside the component. some thing like this

 <set-variable variableName="counter" value="10" />
 <set-property propertyName="testout" value="#[counter]" doc:name="Property" />

Thanks-

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top