2

I am trying to implement a retry advice for a <int-http:outbound-gateway>. I have the following configuration:

<int-http:outbound-gateway 
            request-channel="REQUEST_CHANNEL"
            reply-channel="RESPONSE_CHANNEL"
            url="HTTP_URL"
            http-method="POST"
            charset="UTF-8" 
            header-mapper="headerMapper"
            extract-request-payload="true">
            <int-http:request-handler-advice-chain>
                <ref bean="retryHttpAdvice" />
            </int-http:request-handler-advice-chain>
</int-http:outbound-gateway>

<bean id="headerMapper" class="org.springframework.integration.http.support.DefaultHttpHeaderMapper">
        <property name="outboundHeaderNames" value="HTTP_REQUEST_HEADERS, UserRole" />
        <property name="userDefinedHeaderPrefix" value="" />
</bean>

<int:handler-retry-advice id="retryHttpAdvice" recovery-channel="RECOVERY_CHANNEL" 
        max-attempts="5">
        <int:exponential-back-off 
            initial="1000" 
            multiplier="2" />
</int:handler-retry-advice>

With DEBUG level enabled for the org.springframework.integration in Logback, I can see that RetryAdvice is being executed but without any retry attempt.

Is this the expected behavior? For example, I am getting a 404 error and I expected to see 3 attempts at least (retry count similar to service-activator) but only one at this moment without retry count.

exception is java.net.ConnectException: Connection refused
    at org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler.handleRequestMessage(HttpRequestExecutingMessageHandler.java:409)
    at org.springframework.integration.handler.AbstractReplyProducingMessageHandler$AdvisedRequestHandler.handleRequestMessage(AbstractReplyProducingMessageHandler.java:144)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice$1.cloneAndExecute(AbstractRequestHandlerAdvice.java:92)
    at org.springframework.integration.handler.advice.RequestHandlerRetryAdvice$2.doWithRetry(RequestHandlerRetryAdvice.java:92)
    at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:263)
    at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:193)
    at org.springframework.integration.handler.advice.RequestHandlerRetryAdvice.doInvoke(RequestHandlerRetryAdvice.java:88)
    at org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice.invoke(AbstractRequestHandlerAdvice.java:69)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
    at com.sun.proxy.$Proxy176.handleRequestMessage(Unknown Source)

What is the best way to invoke a retryAdvice with a http-outbound-gateway?

crm86
  • 1,394
  • 1
  • 21
  • 44
  • What are these values? - e.g. `ATTEMPTS` is not a number - I am surprised the context even loads with that - I get a `NumberFormatException`. – Gary Russell Mar 15 '17 at 13:31
  • It was an explanation. All values are correctly set with its formats – crm86 Mar 15 '17 at 14:13
  • I am not sure why you would have changed them in your question; it's not like it's "secret" information. It should work fine then; if you run with DEBUG for `org.springgframewor.retry` and `org.springframework.integration` you should see diagnostic messages about retries. If you still can't figure it out from that, edit your question with details from the logs. – Gary Russell Mar 15 '17 at 14:32

0 Answers0