Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HttpClient httpClient = org.apache.http.impl.client.HttpClientBuilder.create().build();
- HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
- factory.setConnectTimeout((int) TimeUnit.MINUTES.toMillis(2));
- factory.setReadTimeout((int) TimeUnit.MINUTES.toMillis(2));
- factory.setHttpClient(httpClient);
- RestTemplate restTemplate = new RestTemplate(factory);
- int tries, maxRetries = 5;
- Connection connection;
- do {
- try {
- // initialize connection
- } catch (SocketTimeoutException ex) {
- ++tries;
- if (maxRetries < tries) {
- // exit
- }
- // sleep for some time between attempts
- }
- } while (connection == null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement