Search code examples
mulemule-studiomule-componentmule-esb

Mule ESB: How to apply Until Successful Scope to Jersey Resources?


Assume, that we have only one Resouce in our Application: HelloWorldResource

Mule flow configuration looks like this one:

<http:listener-config doc:name="HTTP Listener Configuration" host="0.0.0.0" name="HTTP_Listener_Configuration" port="9988"/>

<flow name="HelloWorldFlow">
    <http:listener config-ref="HTTP_Listener_Configuration" path="/*"/>
     <jersey:resources>
     <component class="acme.HelloWorldResource">
     </component>
 </jersey:resources>
</flow>

And the question that I have right now:

Is it possible to apply Until Successful Scope for Jersey resource?

What exactly I want to achieve: In case, when Jersey resource endpoint failed - I want Mule to retry the call.

I tried to make the following change:

 <until-successful 
        maxRetries="2" 
        millisBetweenRetries="100" 
        objectStore-ref="objectStoreUntilSuccessful" 
        failureExpression="#[message.inboundProperties['http.status'] != 200]">
    <flow name="HelloWorldFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/*"/>
         <jersey:resources>
         <component class="acme.HelloWorldResource">
         </component>
     </jersey:resources>
    </flow>
    </until-successful>

but, my changes just lead to an exception during server startup:

org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'until-successful'

Solution

  • You've put the until-successful outside of the flow, it needs to be inside the flow and just around the jersey:resources element