当前位置: 动力学知识库 > 问答 > 编程问答 >

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"/>

</until-successful>

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

</flow>

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.

Edited:

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

<reconnect-forever />

</http:connector>

<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"/>

</flow>

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"  />
</http:connector>

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

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

or

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

Hope this helps!

Good luck!

分享给朋友:
您可能感兴趣的文章:
随机阅读: