From 84bef6e1bd79dd069e40e9fec6b1f2cc62458439 Mon Sep 17 00:00:00 2001 From: gsavvas Date: Mon, 9 Dec 2024 13:05:24 +0200 Subject: [PATCH] Increase http timeouts to 20 minutes and decouple app config from activemq config --- .../config/application-production.yml | 2 ++ exn-middleware-core/config/application.yml | 2 ++ .../modules/sal/configuration/AppConfig.groovy | 9 --------- .../modules/sal/configuration/ExnConfig.groovy | 16 ++++++++++++++++ .../sal/configuration/RestTemplateConf.groovy | 8 ++++++-- .../config/ConfigureEXNConnector.groovy | 7 +++---- 6 files changed, 29 insertions(+), 15 deletions(-) delete mode 100644 exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/AppConfig.groovy create mode 100644 exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/ExnConfig.groovy diff --git a/exn-middleware-core/config/application-production.yml b/exn-middleware-core/config/application-production.yml index 5603251..af31b0a 100644 --- a/exn-middleware-core/config/application-production.yml +++ b/exn-middleware-core/config/application-production.yml @@ -16,6 +16,8 @@ application: port: '${ACTIVEMQ_PORT:5672}' username: 'admin' password: 'admin' + connectTimeout: 20 #min + readTimeout: 20 #min sal: protocol: 'http' host: '${SAL_HOST:nebulous-sal}' diff --git a/exn-middleware-core/config/application.yml b/exn-middleware-core/config/application.yml index ea601d2..c4cf37a 100644 --- a/exn-middleware-core/config/application.yml +++ b/exn-middleware-core/config/application.yml @@ -17,6 +17,8 @@ application: port: '5672' username: 'admin' password: 'admin' + connectTimeout: 20 #min + readTimeout: 20 #min sal: protocol: 'http' host: 'localhost' diff --git a/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/AppConfig.groovy b/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/AppConfig.groovy deleted file mode 100644 index afc22de..0000000 --- a/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/AppConfig.groovy +++ /dev/null @@ -1,9 +0,0 @@ -package eu.nebulouscloud.exn.modules.sal.configuration - -class AppConfig { - - String url - Integer port - String username - String password -} diff --git a/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/ExnConfig.groovy b/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/ExnConfig.groovy new file mode 100644 index 0000000..999b6af --- /dev/null +++ b/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/ExnConfig.groovy @@ -0,0 +1,16 @@ +package eu.nebulouscloud.exn.modules.sal.configuration + +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.context.annotation.Configuration + +@Configuration +@ConfigurationProperties('application.exn.config') +class ExnConfig { + + String url + Integer port + String username + String password + Long connectTimeout + Long readTimeout +} diff --git a/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/RestTemplateConf.groovy b/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/RestTemplateConf.groovy index 33d9f4d..bfec46e 100644 --- a/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/RestTemplateConf.groovy +++ b/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/configuration/RestTemplateConf.groovy @@ -1,5 +1,6 @@ package eu.nebulouscloud.exn.modules.sal.configuration +import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.web.client.RestTemplateBuilder import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -10,11 +11,14 @@ import java.time.Duration @Configuration class RestTemplateConf { + @Autowired + ExnConfig config + @Bean RestTemplate restTemplateInit(RestTemplateBuilder builder){ - builder.setReadTimeout(Duration.ofMinutes(3)) - .setConnectTimeout(Duration.ofMinutes(1)) + builder.setConnectTimeout(Duration.ofMinutes(config.connectTimeout)) + .setReadTimeout(Duration.ofMinutes(config.readTimeout)) .build() } } diff --git a/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/middleware/config/ConfigureEXNConnector.groovy b/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/middleware/config/ConfigureEXNConnector.groovy index 8ba6ffa..3d0541d 100644 --- a/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/middleware/config/ConfigureEXNConnector.groovy +++ b/exn-middleware-core/src/main/groovy/eu/nebulouscloud/exn/modules/sal/middleware/config/ConfigureEXNConnector.groovy @@ -5,19 +5,18 @@ import eu.nebulouscloud.exn.modules.sal.middleware.handlers.connection.EXNConnec import eu.nebulouscloud.exn.Connector import eu.nebulouscloud.exn.core.Consumer import eu.nebulouscloud.exn.core.Publisher -import eu.nebulouscloud.exn.modules.sal.configuration.AppConfig +import eu.nebulouscloud.exn.modules.sal.configuration.ExnConfig import eu.nebulouscloud.exn.modules.sal.middleware.handlers.consumer.AMQPSalMessageHandler import eu.nebulouscloud.exn.settings.StaticExnConfig import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @Configuration -@ConfigurationProperties(prefix='application.exn') class ConfigureEXNConnector { - AppConfig config + @Autowired + ExnConfig config @Autowired AMQPSalMessageHandler amqpSalMessageHandler