forked from avni-bahmni-integration/integration-service
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#111 - config for timeout with high default value
- Loading branch information
1 parent
c3f291b
commit 865fe00
Showing
6 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
avni/src/main/java/org/avni_integration_service/avni/config/AvniBeanConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.avni_integration_service.avni.config; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.web.client.RestTemplateBuilder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.time.Duration; | ||
|
||
@Configuration | ||
public class AvniBeanConfiguration { | ||
private final RestTemplate restTemplate; | ||
|
||
@Value("${avni.httpClient.timeout}") | ||
private int avniHttpClientTimeout; | ||
|
||
@Autowired | ||
public AvniBeanConfiguration(Environment environment, RestTemplateBuilder restTemplateBuilder) { | ||
Duration timeout = Duration.ofSeconds(avniHttpClientTimeout); | ||
restTemplate = restTemplateBuilder.setConnectTimeout(timeout) | ||
.setReadTimeout(timeout) | ||
.build(); | ||
} | ||
|
||
@Bean("AvniRestTemplate") | ||
public RestTemplate avniRestTemplate() { | ||
return restTemplate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters