Unable to access flowVars(MEL) when it routes through until successful message processor in Mule ESB

StackOverflow https://stackoverflow.com/questions/19380755

  •  30-06-2022
  •  | 
  •  

Question

Hi i'm new to mule and developing mule project for first time, Please help me. In my main flow i have set varaible where i have captured original payload, by the way i have to call one service, if the service is down or something it has to retry 3 times ( so used until successfull). when it exhaused, it has to pass through second flow. Whatever may be the failure it should log only original payload in to the queue in second flow. So i'm trying to access flowVars in setpayload processor. But i'm getting error like - [Error: could not access: originalPayload; in class: org.mule.el.context.MessagePropertyMapContext] [Near : {... flowVars.originalPayload ....}] . Please find my xml config

 <spring:beans> 
    <spring:bean id="objectStore" class="org.mule.util.store.SimpleMemoryObjectStore"></spring:bean>  
</spring:beans>
<vm:endpoint exchange-pattern="one-way" path="path" name="VM" doc:name="VM"></vm:endpoint>
<flow name="Flow1" doc:name="Flow1">
    <file:inbound-endpoint path="C:\Users\Star Jothi\Desktop\Mule\FilePath1" responseTimeout="10000" doc:name="File"/>

    <byte-array-to-string-transformer doc:name="Byte Array to String"></byte-array-to-string-transformer>
    <set-variable variableName="originalPayload" value="#[payload]" doc:name="Variable"/>
    <set-payload value="#['hi']" doc:name="Set Payload"/>
    <flow-ref name="Flow2" doc:name="Flow Reference"/>

</flow>
<flow name="Flow2" doc:name="Flow2">
    <cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP"/>
    <until-successful objectStore-ref="objectStore" maxRetries="2" secondsBetweenRetries="2" deadLetterQueue-ref="VM" doc:name="Until Successful">
        <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="test" method="POST" doc:name="HTTP"/>
    </until-successful>
</flow>
<flow name="Flow3" doc:name="Flow3"> 
   <vm:inbound-endpoint exchange-pattern="one-way" path="path" doc:name="VM"></vm:inbound-endpoint> --> 
    <set-payload value="#[flowVars.originalPayload]" doc:name="Set Payload"></set-payload>  
    <logger message="****#[payload]******" level="INFO" doc:name="Logger"></logger>  
</flow>

Kindly suggest me how to access flowVars and get the original payload when using until successful processor.

Was it helpful?

Solution

First point:

flowVars are accessd in the flow by using #[flowVars['originalPayload']]

Second Point:

flowVars are lost from the Mule Message when the message crosses an endpoint.

Third point:

Until Successful is Asynchronous. So irrespective of the success of Until-Successful and HTTP outbound in First flow  the Flow2 is going to get executed.

In your scenario you can use the HTTP outbound and the Flow2 combination in First Successful router.

Note: First Successful will not retry.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top