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