Http outbound-gateway: is there a way to handle not HTTP errors and, in particular, "no connection" error?

728 Views Asked by At

My gateway can handle HTTP errors by custom error-handler (extends DefaultResponseErrorHandler). But if there is a connection failure error, the gateway is silent.

Gateway schema:

<int-http:outbound-gateway id="myGateway"
                           request-channel="inChannel"
                           reply-channel="outChannel"
                           url="<url>"
                           extract-request-payload="true"                                
                           request-factory="clientHttpRequestFactory"
                           expected-response-type="java.lang.String"
                           error-handler="myRespErrHandler"/>

<bean 
    id="httpComponentsMessageSender"
    class="org.springframework.ws.transport.http.HttpComponentsMessageSender"/>
<bean 
    id="clientHttpRequestFactory"
    class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">
        <property name="httpClient" value="#{httpComponentsMessageSender.httpClient}"/>
</bean>

Is there a way to handle such errors? Thanx in advance.

1

There are 1 best solutions below

1
On BEST ANSWER

Yes. It is called request handler advice. You can use a retry one for reconnecting attempts or you can handle non-HTTP errors using expression advice: https://docs.spring.io/spring-integration/docs/5.0.8.RELEASE/reference/html/messaging-endpoints-chapter.html#message-handler-advice-chain