How long are requests stored in apache tomcat request queue? - spring-boot

Is there a timeout setting for requests stored in the apache tomcat request queue? If yes, what is the default value for the embedded tomcat in spring boot?

When configuring a web server, it also might be useful to set the server connection timeout. This represents the maximum amount of time the server will wait for the client to make their request after connecting before the connection is closed.
You may specify this property in your application.properties as follows.
server.connection-timeout=5s

Related

What is the default queue size for apache tomcat in spring boot?

What is the default request queue size in apache tomcat which is embedded in spring boot ?
As of spring boot version 2.7.2, this is set to 100 by default. You can use the following property to change it:
server.tomcat.accept-count=100
According to the documentation this is used to specify:
Maximum queue length for incoming connection requests when all possible request processing threads are in use.
To check for the version you're using, you can try replacing the version in this url & searching for acceptCount.
The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. In Spring Boot, we can define the maximum amount of Tomcat worker threads are 200. You may specify this property in your application.properties as follows.
server.tomcat.max-threads=200

Spring Boot 2 + Websockets + Load balancer

We have written simple message sending mechanism to client (logged in user based) from server by using spring boot + websocket.
Currently its running in a single server, which is working fine.
But our production servers running under load balancing environment.
How could we achieve where the messages are pushed from server nodes send to appropriate users.
Please advice the possibilities, I have read some articles about RabbitMQ with socketjs , but not clear will it work for load balancing.
Thanks
If you have multiple instances of your websocket server, then every instance needs to know the sessions that exists on other instances.
Therefore you need to use a broker relay (not the in-memory broker given by spring) and set the UserRegistryBroadcast property.
You can find some info related to this at the end of this talk https://www.youtube.com/watch?v=nxakp15CACY

How to refresh config clients automatically?

I am new to Spring Config Server/Client technologies.
I am using a spring config server to hold some config values.
Config clients will connect to the server and get the values.
If i change some of the config values at the config server, then currently I have to refresh the clients to load the config details from config server again by invoking "/refresh" on each client.
Is there anyway the clients will be notified by the config server and they will then reload the configuration again ?
Yes there is a way.
The solution is to use the Spring Cloud Bus. Using this module, you would link multiple clients to the server using a message broker. The only message broker implementation currently supported by this module is AMQP. Once the clients are connected to the server, invoking the endpoint on the server /bus/refresh will automatically broadcast the configuration changes to all the subscribed clients. This therefore means it is possible to reload configuration changes for any number of clients with one single refresh request which originates at the server.

Websphere SOAP timeout

From EJB transaction I am calling remote site using SOAP. Remote server is not responding. I got transaction time-out. But I want to get time-out from remote call.
How can I set time-out for SOAP request globally?
How can I set time-out for SOAP request for particular call?
You should be able to configure this using a Policy Set. See the link below for IBM's documentation on the topic.
http://pic.dhe.ibm.com/infocenter/wasinfo/v8r5/index.jsp?topic=%2Fcom.ibm.websphere.nd.doc%2Fae%2Frwbs_jaxwstimeouts.html
To globally set timeout, you may use HTTP transport custom properties for web services applications. The timeout you're looking for here is timeout. This is by default 300 seconds (which is more than global transaction timeout default value, which is 120 seconds, hence you receive a transaction time-out).
If you are using JAX-RPC, make sure you are at a patch level containing fix for PM60752 (6.1.0.45, 7.0.0.25, 8.0.0.5 and 8.5.0.1).
As indicated at Nick's answer, you have alternative methods to configure timeouts if you are using the newer JAX-WS stack.
When using JAX-RPC you may set timeout for a particular call endpoint as explained in article Setting the timeout value for a JAX-RPC Web Service client. For JAX-WS you may use bindings or go for one of the solutions at How to Set Timeout for JAX-WS WebService Call.
One thing to keep in mind when configuring timeouts for web services is that web service transport depends on HTTP transport (assuming SOAP over HTTP), and in turn that depends on TCP transport, all of which are configurable for various timeouts. The relations between these layers and solutions to common problems are outlined at Common Timeouts effecting Web Services, HTTP and SOAP clients article.

HTTP Connection pool

I need to set up an HTTP connection pool in a Spring app on a Tomcat server.
We are debating whether to define the pool at the application or at the server level (applicationContext.xml vs server.xml).
My problem is: I've looked and I've looked, but I just can't find any info on doing either.
For now, I'm working with org.apache.http.impl.conn.PoolingClientConnectionManager inside my class, and it's working ok.
How would I be able to define a pool outside my Java code and work with it from there?
Here is the configuration reference you are looking for for tomcat 7:
http://tomcat.apache.org/tomcat-7.0-doc/config/http.html#Standard_Implementation
Here is also another SO post on the same subject: How to increase number of threads in tomcat thread pool?

Resources