I am using Spring MVC with Spring 3.1. I have a web application that uses many REST services. One of these REST services takes up to an hour to respond - which I can not change. I have my timeout for the RestTemplate set up like this with the timeout set to 60 minutes:

<bean id="restTemplate" class="org.springframework.web.client.RestTemplate ">
    <constructor-arg>
        <bean class="org.springframework.http.client.CommonsClientHttpRequestFactory">
            <property name="readTimeout" value="3600000" />
            <property name="connectTimeout" value="3600000" />
        </bean>
    </constructor-arg>
</bean>

I would like to be able to set all of my other REST calls to a different set of timeouts. Any ideas on how to do this?

Thanks,

Tim

有帮助吗?

解决方案

You can't do this on a method call basis. In other words, all calls on the restTemplate bean will use the same underlying ClientHttpRequestFactory. If you want different requests to use different timeout values, declare multiple RestTemplate beans and inject the appropriate ones in your beans.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top