Until Successful 

 

The Until Successful scope processes the components within it until they succeed or exhaust the maximum number of retries. UntilSuccessful runs synchronously. If a component within the scope fails to connect or produce a successful result, Until Successful retries the failed task until all configured retries are exhausted. If a retry succeeds, the scope proceeds to the next component. If the final retry does not succeed, UntilSuccessful produces an error.

Create a project in anypoint studio and configure the listener

Drag and drop Until Successful from mule palette

Configure the below parameters

  • Max Retries: Specifies the maximum number of retries that are attempted
  • Milliseconds Between Retries: Specifies the minimum interval between two attempts to process, in milliseconds, Default value is 1 Min

Wrap the HTTP Requester inside Until Successful

To replicate the UntilSuccessful Scope I have configured the Retries Interval as 30 ms (You can configure as per the requirement)

Until Successful

 

Configure the HTTP Requester and to replicate the failure Scenario configure the http response statue code as 500, in that case response will be treated as failure with http status code 500 and untilsuccessful will be executed

Until Successful

 

In Response section

Until Successful

 

Deploy the project and test the same from soapui

See the error ‘until-successful’ retries exhausted’ and Error Type is MULE:RETRY_EXHAUSTED

 

Message : 'until-successful' retries exhausted. Last exception message was: HTTP GET on resource 'http://dummy.restapiexample.com:80/api/v1/employees' failed with status code 200.
 
Error type : MULE:RETRY_EXHAUSTED
 
Element : org.mule.runtime.core.internal.routing.UntilSuccessful@2cd6f4a8 @ app:untilsuccessful.xml:15 (Until Successful)
 
Element XML : 
<until-successful maxRetries="5" doc:name="Until Successful" doc:id="ed2a6567-029f-4b06-939f-f2d54f8c9516" millisBetweenRetries="30">
  <http:request method="GET" doc:name="Request" doc:id="f3d39835-797a-4cca-9fad-2f5ac9e9942c" path="/api/v1/employees" config-ref="HTTP_Request_configuration">
    <http:response-validator>
      <http:success-status-code-validator values="500"/>
    </http:response-validator>
  </http:request>
</until-successful>

In case of success scenario there will not be any error received from Rest API(http status will be 200) and success response will be retrieved. In case of success either the UntilSuccessful scope will not be executed or it could be that the success response is received once retry succeed after few attempts

Sample application: Untilsuccessful sample application

Sample soapui project : untilsuccessful soapui project

  
Thank you for taking out time to read the above post. Hope you found it useful. In case of any questions, feel free to comment below. Also, if you are keen on knowing about a specific topic, happy to explore your recommendations as well.
 
For any latest updates or posts on our website, you can follow us on LinkedIn. Look forward to connecting with you there.


Share this:
Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
lokesh
lokesh
2 years ago

you mentioned one snippet In Response section it should be a failure status code validator. instead of success status code validator.

correct if I am wrong.

Last edited 2 years ago by lokesh