歡迎來到DIVCSS5查找CSS資料與學習DIV CSS布局技術!
Java Config配置
 
@Configuration
 
public class RestTemplateConfig {
 
    @Bean
 
    public RestTemplate getRestTemplate() {
 
        //配置HTTP超時時間
 
        HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory();
 
        httpRequestFactory.setConnectionRequestTimeout(6000);
 
        httpRequestFactory.setConnectTimeout(6000);
 
        httpRequestFactory.setReadTimeout(6000);
 
        return new RestTemplate(httpRequestFactory);
 
    }
 
}
 
配置文件指定
 
custom.rest.connection.connection-request-timeout=3000
 
custom.rest.connection.connect-timeout=3000
 
custom.rest.connection.read-timeout=3000
 
@Configuration
 
public class AppConfig{
 
    @Bean
 
    @ConfigurationProperties(prefix = "custom.rest.connection")
 
    public HttpComponentsClientHttpRequestFactory customHttpRequestFactory() {
 
        return new HttpComponentsClientHttpRequestFactory();
 
    }
 
    @Bean
 
    public RestTemplate customRestTemplate(){
 
        return new RestTemplate(customHttpRequestFactory());
 
    }
 
}
 
重新部署后消費者迅速開始消費,堆積的消息已經消費完。

如需轉載,請注明文章出處和來源網址:http://www.rs2pl.com/html/h65264.shtml

久久天天躁狠狠躁夜夜躁2020