From 777911fea8f0508494b64a8dcfe22690c5a67046 Mon Sep 17 00:00:00 2001 From: urviljoshi Date: Tue, 27 Sep 2022 15:40:22 +0530 Subject: [PATCH 1/5] resttemplate issue resolved version modified to p1 --- partner/partner-management-service/pom.xml | 4 +-- partner/pms-common/pom.xml | 2 +- .../io/mosip/pms/common/util/RestUtil.java | 28 ++++++++++++------- partner/policy-management-service/pom.xml | 4 +-- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/partner/partner-management-service/pom.xml b/partner/partner-management-service/pom.xml index 7095697fbf..4629dcf346 100644 --- a/partner/partner-management-service/pom.xml +++ b/partner/partner-management-service/pom.xml @@ -8,7 +8,7 @@ 1.1.5.4 - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT partner-management-service partner-management-service @@ -31,7 +31,7 @@ io.mosip.pms pms-common - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT org.springframework.boot diff --git a/partner/pms-common/pom.xml b/partner/pms-common/pom.xml index 4e6725da57..5732f53233 100644 --- a/partner/pms-common/pom.xml +++ b/partner/pms-common/pom.xml @@ -9,7 +9,7 @@ 1.1.5.4 pms-common - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT pms-common UTF-8 diff --git a/partner/pms-common/src/main/java/io/mosip/pms/common/util/RestUtil.java b/partner/pms-common/src/main/java/io/mosip/pms/common/util/RestUtil.java index ab4657ae03..b7a91987a8 100644 --- a/partner/pms-common/src/main/java/io/mosip/pms/common/util/RestUtil.java +++ b/partner/pms-common/src/main/java/io/mosip/pms/common/util/RestUtil.java @@ -23,6 +23,7 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.TrustStrategy; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -54,6 +55,14 @@ public class RestUtil { private Environment environment; private static final String AUTHORIZATION = "Authorization="; + + private RestTemplate localRestTemplate; + + @Value("${pms.default.httpclient.connections.max.per.host:20}") + private int maxConnectionPerRoute; + + @Value("${pms.default.httpclient.connections.max:100}") + private int totalMaxConnection; @SuppressWarnings("unchecked") public T postApi(String apiUrl, List pathsegments, String queryParamName, String queryParamValue, @@ -169,16 +178,15 @@ public T getApi(String apiUrl, Map pathsegments, Class re } public RestTemplate getRestTemplate() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException { - TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; - SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy) - .build(); - SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext); - CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build(); - HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); - requestFactory.setHttpClient(httpClient); - - return new RestTemplate(requestFactory); - + if(localRestTemplate==null) { + HttpClientBuilder httpClientBuilder = HttpClients.custom() + .setMaxConnPerRoute(maxConnectionPerRoute) + .setMaxConnTotal(totalMaxConnection).disableCookieManagement(); + HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); + requestFactory.setHttpClient(httpClientBuilder.build()); + localRestTemplate= new RestTemplate(requestFactory); + } + return localRestTemplate; } @SuppressWarnings("unchecked") diff --git a/partner/policy-management-service/pom.xml b/partner/policy-management-service/pom.xml index 7eb7197125..28b7e8990c 100644 --- a/partner/policy-management-service/pom.xml +++ b/partner/policy-management-service/pom.xml @@ -7,7 +7,7 @@ io.mosip.pms 1.1.5.4 - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT policy-management-service policy-management-service @@ -19,7 +19,7 @@ io.mosip.pms pms-common - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT io.micrometer From 9230cdd017def112f85191a1b3dced682affe966 Mon Sep 17 00:00:00 2001 From: Urvil Joshi <42868205+urviljoshi@users.noreply.github.com> Date: Wed, 28 Sep 2022 19:34:26 +0530 Subject: [PATCH 2/5] module commented --- partner/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/partner/pom.xml b/partner/pom.xml index 55d4e95276..1c13397866 100644 --- a/partner/pom.xml +++ b/partner/pom.xml @@ -5,7 +5,7 @@ io.mosip.pms pms-parent pom - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT partner-management-services Parent project of MOSIP partner-management-services @@ -72,7 +72,7 @@ - policy-validator + pms-common policy-management-service partner-management-service @@ -273,4 +273,4 @@ - \ No newline at end of file + From 3a89ef02aee152fc0fff675a790cf443058c628b Mon Sep 17 00:00:00 2001 From: Urvil Joshi <42868205+urviljoshi@users.noreply.github.com> Date: Wed, 28 Sep 2022 19:34:54 +0530 Subject: [PATCH 3/5] parent version modified --- partner/pms-common/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/partner/pms-common/pom.xml b/partner/pms-common/pom.xml index 5732f53233..5f0ef67ae2 100644 --- a/partner/pms-common/pom.xml +++ b/partner/pms-common/pom.xml @@ -6,7 +6,7 @@ io.mosip.pms pms-parent - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT pms-common 1.1.5.4-p1-SNAPSHOT @@ -40,4 +40,4 @@ ${kernel-websubclient-api.version} - \ No newline at end of file + From b9a1874649373f4c0f440469cd0563e348d11afd Mon Sep 17 00:00:00 2001 From: Urvil Joshi <42868205+urviljoshi@users.noreply.github.com> Date: Wed, 28 Sep 2022 19:35:40 +0530 Subject: [PATCH 4/5] parent version modified --- partner/policy-management-service/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/partner/policy-management-service/pom.xml b/partner/policy-management-service/pom.xml index 28b7e8990c..54c787eaea 100644 --- a/partner/policy-management-service/pom.xml +++ b/partner/policy-management-service/pom.xml @@ -5,7 +5,7 @@ pms-parent io.mosip.pms - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT 1.1.5.4-p1-SNAPSHOT policy-management-service @@ -118,4 +118,4 @@ - \ No newline at end of file + From 51797b3a1f3ccaf1c96c1b6728c62a3535c50dcc Mon Sep 17 00:00:00 2001 From: Urvil Joshi <42868205+urviljoshi@users.noreply.github.com> Date: Wed, 28 Sep 2022 19:35:44 +0530 Subject: [PATCH 5/5] parent version modified --- partner/partner-management-service/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/partner/partner-management-service/pom.xml b/partner/partner-management-service/pom.xml index 4629dcf346..f2d691947c 100644 --- a/partner/partner-management-service/pom.xml +++ b/partner/partner-management-service/pom.xml @@ -5,7 +5,7 @@ pms-parent io.mosip.pms - 1.1.5.4 + 1.1.5.4-p1-SNAPSHOT 1.1.5.4-p1-SNAPSHOT @@ -112,4 +112,4 @@ - \ No newline at end of file +