

Mule ESB: How to achieve unlimited Retry till the consuming Service is up and running


I'm not sure how to apply logic to handle this issue.

I have a simple flow, Where I'm consuming the service in between the flow. I have tried until successful, but it required Max retries field( but I dont want to limit my retry by giving any number). To my scenario, I'm not sure when my consuming service is up, But need to retry until the service up and running ( not required retry exhausted). Could anyone suggest to handle the scenario.

 <flow name="newFlow1" doc:name="newFlow1">

<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="ttt" doc:name="HTTP"/>

<byte-array-to-string-transformer doc:name="Byte Array to String"/>

<logger message="**********test****#[payload]" level="INFO" doc:name="Logger"/>

<until-successful doc:name="Until Successful">

<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8089" path="new" method="POST" doc:name="HTTP"/>


<set-payload value="'Return Response'" doc:name="Set Payload"/>


Also tried Max Retries in until successful as '-1'( to make as unlimited retry) but it is not accepting the negative value.

Tried using HTTP connector retry connection strategy(but it seems to be work for JMS or JDBC).

Could you please anyone suggest to handle this issue.

Thanks in advance.


 <http:connector name="HttpConnector" doc:name="HTTP-HTTPS">

<reconnect-forever />


<flow name="new1Flow1" doc:name="new1Flow1">

<http:inbound-endpoint exchange-pattern="request-response" doc:name="HTTP" path="ttt" responseTimeout="30000" host="localhost" port="8081" />

<logger message="***entered***" level="INFO" doc:name="Logger"/>

<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8089" path="new" connector-ref="HttpConnector" method="POST" doc:name="HTTP"/>

<logger message="**Http StatusCode***#[message.inboundProperties['http.status']]" level="INFO" doc:name="Logger"/>


It is not doing retry, since the service is down I could see the following error message in console for one time only.( But we should get multiple times the error message in console until service up)

 Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://localhost:8089/new, connector=HttpConnector

Please suggest.


You can first define a http Connector which will have a property of reconnecting forever

<http:connector name="HttpConnector" >
    <reconnect-forever  frequency="2000"  />

then you can have your inbound-or outbound endpoint use that connector reference like this

 <http:inbound-endpoint connector-ref="HttpConnector" .../>


<http:outbound-endpoint connector-ref="HttpConnector" .../>

Hope this helps!

Good luck!