max max - 4 months ago 81
HTTP Question

Mule 3.7 until successful failureExpression not working

I am using until-successful to retry calling a web service only when it is down.

Below is what I have tried:

<until-successful maxRetries="10" failureExpression="#[(message.inboundProperties['http.status'] != 200) &amp;&amp; (message.inboundProperties['http.status'] != 500)]" synchronous="true" millisBetweenRetries="5000">

<flow-ref name="callSubFlow" doc:name="Flow Reference"/>




If I get a HTTP response 500 I also do not want to retry calling the web service. I have mocked a web service and when it returns a HTTP 500 response the until successful keeps retrying calling the web service. What is wrong with the failureExpression above?

Thanks

max max
Answer

Here is how if fixed my issue. I created another flow that catches only the Web Service 500 error. The until -successful then does not retry to call the web service again.

<until-successful maxRetries="${webservice.timeout.max.retries}" failureExpression="#[exception != null &amp;&amp; (exception.causedBy(java.net.ConnectException) || exception.causedBy(java.net.SocketTimeoutException) || exception.causedBy(java.util.concurrent.TimeoutException) || exception.causedBy(java.net.SocketException))]" 
synchronous="true" millisBetweenRetries="5000" >
 <processor-chain doc:name="Processor Chain">


      <set-payload value="#[payLoad]" />
      <flow-ref name="Flow1" />

  </processor-chain>
</until-successful>

<flow name="Flow1">
<ws:consumer config-ref="WSConsumerConfig" operation="execute"  />
    <choice-exception-strategy doc:name="Choice Exception Strategy">


      <catch-exception-strategy doc:name="Catch Exception Strategy" when="#[exception != null &amp;&amp; exception.causedBy(org.mule.module.ws.consumer.SoapFaultException)]">

        <logger message="SoapFaultException occurred." level="INFO" doc:name="Logger"/>
        <set-payload value="#[exception]" doc:name="Set Payload"></set-payload>
     </catch-exception-strategy>

    </choice-exception-strategy>
</flow>