Loading

How to Retry a Failed HTTP Request Due to HTTP:CONNECTIVITY or Other Errors in Mule 4

Дата публикации: Mar 2, 2024
Задача

GOAL

You want to perform continuous retries on a HTTP request that fails due to HTTP:CONNECTIVITY or other errors in Mule 4.

Действия
  1. You will need to use the until-successful scope
  2. You should wrap your request with the until-successful scope:
    User-added image
  3. You should see the following logs like this:
    ERROR 2021-05-26 14:13:29,461 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.15 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.extension.http.internal.request.HttpRequester: Error sending HTTP request to http://localhost:8080/path8080
    ERROR 2021-05-26 14:13:29,470 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.15 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.runtime.core.internal.routing.UntilSuccessfulRouter: Retrying execution of event, attempt 1 of 5.
    ERROR 2021-05-26 14:13:34,476 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.14 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.extension.http.internal.request.HttpRequester: Error sending HTTP request to http://localhost:8080/path8080
    ERROR 2021-05-26 14:13:34,477 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.14 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.runtime.core.internal.routing.UntilSuccessfulRouter: Retrying execution of event, attempt 2 of 5.
    ERROR 2021-05-26 14:13:39,480 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.13 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.extension.http.internal.request.HttpRequester: Error sending HTTP request to http://localhost:8080/path8080
    ERROR 2021-05-26 14:13:39,480 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.13 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.runtime.core.internal.routing.UntilSuccessfulRouter: Retrying execution of event, attempt 3 of 5.
    ERROR 2021-05-26 14:13:44,483 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.12 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.extension.http.internal.request.HttpRequester: Error sending HTTP request to http://localhost:8080/path8080
    ERROR 2021-05-26 14:13:44,484 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.12 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.runtime.core.internal.routing.UntilSuccessfulRouter: Retrying execution of event, attempt 4 of 5.
    ERROR 2021-05-26 14:13:49,488 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.11 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.extension.http.internal.request.HttpRequester: Error sending HTTP request to http://localhost:8080/path8080
    ERROR 2021-05-26 14:13:49,488 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.11 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.runtime.core.internal.routing.UntilSuccessfulRouter: Retrying execution of event, attempt 5 of 5.
    ERROR 2021-05-26 14:13:54,493 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.10 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.extension.http.internal.request.HttpRequester: Error sending HTTP request to http://localhost:8080/path8080
    ERROR 2021-05-26 14:13:54,494 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.10 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.runtime.core.internal.routing.UntilSuccessfulRouter: Retry attempts exhausted. Failing...
    ERROR 2021-05-26 14:13:54,496 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.10 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: 
    ********************************************************************************
    Message               : 'until-successful' retries exhausted. Last exception message was: HTTP GET on resource 'http://localhost:8080/path8080' failed: Connection refused.
    Element               : workshopFlow/processors/0 @ http-retry-poc:workshop.xml:22 (Until Successful)
    Element DSL           : <until-successful maxRetries="5" doc:name="Until Successful" doc:id="8b201a98-468e-440d-8244-9ed6e574d5bf" millisBetweenRetries="5000">
    <http:request method="GET" doc:name="connectivity error" doc:id="32ca4d42-0e59-4e57-a159-afb5074da335" config-ref="HTTP_Request_configuration_HTTP:CONNECTIVITY" path="/path8080"></http:request>
    </until-successful>
    Error type            : MULE:RETRY_EXHAUSTED
    FlowStack             : at workshopFlow(workshopFlow/processors/0 @ http-retry-poc:workshop.xml:22 (Until Successful))
    
      (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
    ********************************************************************************
    
    DEBUG 2021-05-26 14:13:54,550 [[http-retry-poc].http.requester.HTTP_Request_configuration_HTTP:CONNECTIVITY.10 SelectorRunner] [processor: workshopFlow/processors/0/processors/0; event: 37ec3cf0-be67-11eb-8b3c-147ddab8b9eb] org.mule.service.http.impl.service.HttpMessageLogger.HTTP_Listener_config: LISTENER
    HTTP/1.1 500 Server Error
    Content-Type: text/plain; charset=UTF-8
    Content-Length: 147
    Date: Wed, 26 May 2021 21:13:54 GMT
    Connection: close
    
    'until-successful' retries exhausted. Last exception message was: HTTP GET on resource 'http://localhost:8080/path8080' failed: Connection refused.
Номер статьи базы знаний

001116223

 
Загрузка
Salesforce Help | Article