Time Out Exception for all requests in Spring Boot application - java

I want to stop the services after 30Sec.
Here I'm using SpringBoot application and it has many Rest API's. Default time out is 60Sec in tomcat.

Set this property in application.properties
server.tomcat.connection-timeout=30s
You can find all configuration properties of Spring Boot in the documentation: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#common-application-properties

Related

How to configure multiple spring cloud config servers in spring boot

I am using spring boot 2.4 and application related properties are stored in spring cloud config server. It works fine and I am able to read all properties in the application. Below properties have been configured in application.properties for this purpose.
spring.application.name=app-prop-config
spring.cloud.config.label=61465
spring.cloud.config.enable=true
spring.config.import=configserver:https://vmcloud-configsvc.farm-dev.ab.com
The above properties translates to: https://vmcloud-configsvc.farm-dev.ab.com/61465/app-prop-config-dev.properties
Per my requirement, I need to read few more properties as well and these properties are already available in another spring cloud config server which can be accessed using:
spring.application.name=common-prop-config
spring.cloud.config.label=61468
spring.cloud.config.enable=true
spring.config.import=configserver:https://vmcloud-common-configsvc.farm.ab.com
The above properties translates to: https://vmcloud-common-configsvc.farm.ab.com/61468/common-prop-config-dev.properties
The above config server(https://vmcloud-common-configsvc.farm.ab.com) properties have been used by multiple applications and duplicating properties into my config server(https://vmcloud-configsvc.farm-dev.ab.com) would cause maintenance issue in future as any change in properties have to get updated in 2 servers.
Is it possible to use above 2 spring cloud config servers in spring boot app so that I don't have to copy required properties into my existing config server?
Hi it's working for me when i use bootstrap first config. You can put multiple config name that you want to load. For example if you want to retreive user-service.properties et data-rest.properties in the same app your bootstrap.properties should be like:
spring.cloud.config.uri= http://config-server-host
spring.cloud.config.name= user-service, data-rest

How to modify Wildfly/JBoss config using Spring Boot

I'm migrating a Spring MVC web application to a Spring Boot. The build (maven) generates a .war file then I upload it to Wildfly Server. I used to be able to upload large file now it doesn't work.
On the old way, using Spring MVC, I updated the Wildfly' server config itself /standalone/configuration/standalone-full.xml which no longer work after switching to Spring Boot
<http-listener name="default" socket-binding="http" max-post-size="304857600" redirect-socket="https" enable-http2="true"/>
So the config above says allow posting files up to ~300MB (see the 304857600)
How to modify Wildfly/JBoss config using Spring Boot?
My google search was redirected here by some user comment, but still unsure how to do it in Spring Boot
https://docs.jboss.org/author/display/WFLY10/Undertow+subsystem+configuration
I'm on:
JDK 1.8
spring-boot-2.1.2.RELEASE.jar
spring-core-5.1.2.RELEASE.jar
Wildfly 10.
SpringBoot ask to setup these two additional config parameter to control the size limits of file upload/post request. I am certain that's causing the limitation in your case, if your Wildfly server is configured to not limit it.
#Max file size.
spring.servlet.multipart.max-file-size
#Max Request Size
spring.servlet.multipart.max-request-size
Reference: SpringBoot guide for file upload feature.

How to disable write operation for Jolokia in Spring boot?

I have a Spring boot (v1.5.9) based application with Jolokia provided by Spring boot actuator.
Jolokia works fine. I can read values, for example:
http://localhost:8080/jolokia/read/java.lang:type=ClassLoading/Verbose
gives me:
{"request":{"mbean":"java.lang:type=ClassLoading","attribute":"Verbose","type":"read"},"value":false,"timestamp":1527859447,"status":200}
What I want is to disable writing operations, for example:
http://localhost:8080/jolokia/write/java.lang:type=ClassLoading/Verbose/true
The spring boot configuration looks like this:
management.security.enabled=false
management.endpoints.jmx.exposure.exclude=*
management.endpoints.web.exposure.include=jolokia,metrics
management.endpoint.jolokia.config.policyLocation=classpath:/jolokia.xml
And the Jolokia's policy in WEB-INF\classes\jolokia.xml (in resulting war, according to https://jolokia.org/reference/html/security.html) contains:
<restrict>
<commands>
<command>read</command>
<command>list</command>
<command>version</command>
<command>search</command>
</commands>
</restrict>
Despite this I see the following note in application's log:
jolokia: No access restrictor found, access to any MBean is allowed
And the write operation from the example above is working fine.
What I'm doing wrong? Should I put the policy file somewhere else? Is it possible to configure Jolokia's policy directly from the Spring boot configuration?
It looks like you've inadvertently used Spring Boot 2.0 configuration properties with Spring Boot 1.5.x. In 1.5 you should use jolokia.config.policyLocation. There's a little more information in the reference documentation.

yaml configuration in spring mvc (But not using spring-boot)

Is there a way to enable yaml configuration (instead of properties file) in normal spring web mvc application without using spring boot and have the #Value annotation supported.
I searched a lot, everywhere it uses spring boot. I am not intrested to use spring boot, as its very heavy and have many dependancies configured for auto setup.
Any help would be appreciated......

How to define a Shared DataSource in Spring Cloud Config

Would it be possible to set up a DataSource using Spring Cloud in which open JDBC connections could be injected into all of my Spring Boot applications?
Something kind of like a JNDI server lookup? If so, can someone provide some examples or a description on how to use this type of configuration?
You could use a Spring Cloud bootstrap configuration to create a DataSource. I don't see much value in doing it that way over a normal Spring Boot autoconfiguration though. Link: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-developing-auto-configuration.
One solution I found out was to set all datasources info into the properties files which will supplied by Spring Cloud Config Server to applications clients. So the aplications clients which creates DataSources gets from remote properties those values.

Categories