Pete
Pete

Reputation: 47

Spring Integration AMQP - message unacked occasionally, need a timeout?

I have an inbound RabbitMQ channel adapter that successfully processes 3000 messages per day, however very occasionally I see a unacked message count of 1 in the RabbitMQ admin console. This seems to remain like that.

I do have a re-try advice chain to re-try 3 times and then move to a DLQ via a dead letter routing key, this has worked fine for most exceptions.

The unacked has happened twice in the last few weeks, and on one of the occasions I was able to take a thread dump and see that the int-http:outbound-gateway call was stuck waiting for a http response getStatusCode()

I have a receive-timeout="59000" on the int-amqp:inbound-channel-adapter which I was hoping would timeout the thread anywhere it exceeds the timeout ?

I now notice there is a reply-timeout attribute on the int-http:outbound-gateway should I be setting that ?

Any ideas appreciated ?

    <int-amqp:inbound-channel-adapter id="amqpInCdbEvents"  channel="eventsAMQPChannel" channel-transacted="true"  transaction-manager="transactionManager" 
            queue-names="internal.events.queue" connection-factory="connectionFactory" 
            receive-timeout="59000" concurrent-consumers="${eventsAMQPChannel.concurrent-consumers}" 
            advice-chain="retryChain" auto-startup="false" /> 

     <int:channel id="eventsAMQPChannel" />

     <!--  CHAIN of processing for Asynch Processing of Events from intermediate Queue   -->
    <int:chain id="routeEventChain" input-channel="eventsAMQPChannel">
            <int:json-to-object-transformer type="xx.xx.xx.json.Event" object-mapper="springJacksonObjectMapper"/>
            <int:header-enricher>
                  <int:header name="originalPayload" expression="payload" overwrite="true"/>
                  <int:header name="message_id"      expression="payload.id" overwrite="true"/>
            </int:header-enricher>  
            <int:router expression="payload.eventType">
                <int:mapping value="VALUE"              channel="valueEventChannel"/>
                <int:mapping value="SWAP"               channel="swapEventChannel"/>
            </int:router>
    </int:chain>

    <int:channel id="valueEventChannel" />
    <int:channel id="swapEventChannel" />

    <int:chain id="valueEventChain" input-channel="valueEventChannel" output-channel="nullChannel">
            <int:transformer ref="syncValuationTransformer" />
            <int:object-to-json-transformer object-mapper="springJacksonObjectMapper" />
            <int:header-enricher>
                     <int:header name="contentType" value="application/json;charset=UTF-8" overwrite="true"/>
            </int:header-enricher>                  
            <int-http:outbound-gateway id="httpOutboundGatewayValuationServiceFinalValuation"                                                           
                    expected-response-type="java.lang.String"
                    http-method="POST"      charset="UTF-8"
                    extract-request-payload="true"                                          
                    url="${value.service.uri}/value"/>
    </int:chain>

Upvotes: 1

Views: 525

Answers (1)

Gary Russell
Gary Russell

Reputation: 174739

reply-timeout is a timeout when sending the reply to the reply channel (if it can block - e.g. a bounded queue channel that's full).

int-http:outbound-gateway call was stuck waiting for a http response getStatusCode()

You set the client timeout (readtimeout) on a ClientHttpRequestFactory that you can configure into the outbound adapter...

/**
 * Create a new instance of the {@link RestTemplate} based on the given {@link ClientHttpRequestFactory}.
 * @param requestFactory HTTP request factory to use
 * @see org.springframework.http.client.SimpleClientHttpRequestFactory
 * @see org.springframework.http.client.HttpComponentsClientHttpRequestFactory
 */
public RestTemplate(ClientHttpRequestFactory requestFactory) {
    this();
    setRequestFactory(requestFactory);
}

Upvotes: 0

Related Questions