hocikto
hocikto

Reputation: 981

Spring retry template with proxy

I have a RestTemplate that has a proxy set up such as

Proxy proxy = new Proxy(Type.HTTP, new InetSocketAddress(config.getProxyHost(), config.getProxyPort()));
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
requestFactory.setProxy(proxy);

restTemplate = new RestTemplate(requestFactory);

Now I also tried this with RetryTemplate and it does not work obviously there is no constructor like this

RetryTemplate retryTemplate = new RetryTemplate(requestFactory); // does not work

Is there any way to set the proxy settings to RetryTemplate as it is for RestTemplate?

Upvotes: 0

Views: 547

Answers (1)

Gary Russell
Gary Russell

Reputation: 174664

It is not clear what you are trying to do. The proxy is for talking over HTTP, the retry template has nothing to do with HTTP.

If you want to retry calls to your rest template, use

... = retryTemplate.execute(context -> {
    return restTemplate....();
}

Upvotes: 1

Related Questions