I stored some information in a variable, but I do not know how to access it in my java code...
Example:
<sub-flow name="EnrichMessage" doc:name="EnrichMessage">
<component doc:name="Scenario01" class="Class01"/>
<set-variable variableName="Parameters" value="#[payload]" doc:name="Variable"/>
<flow-ref name="SubFlow01" doc:name="SubFlow01"/>
<component doc:name="Scenario02" class="Class02"/>
</sub-flow>
I already saw some incomplete answers, but still don't know how to do that. Anyone can post a complete answer?
Thanks.
In java there are a few ways to access variables depending the type of java class you are using:
onCall event class
public Object onCall(MuleEventContext eventContext, @Payload String payload)
throws Exception {
String returnPath = eventContext.getMessage().getProperty("myReturnPath", PropertyScope.OUTBOUND);
If the MuleMessage is passed:
public void process(@Payload MuleMessage payload ){
String returnPath = messge.getProperty("myReturnPath", PropertyScope.OUTBOUND);
Using an OutboundHeader annotation
public void process(@Payload String payload, @OutboundHeaders Map headers ){
String prop = headers.get("propname");