Spring Tomcat boot configuration, transition from container to embedded

I am migrating the Spring boot application that was used to run in the Tomcat container to the Spring boot application that launches the built-in Tomcat. My old Tomcat configuration has these configurations in the server.xml file:

<Connector executor="tomcatThreadPool" port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" acceptCount="500" acceptorThreadCount="2" maxThreads="150" maxHttpHeaderSize="32768" maxHeaderCount="256" connectionTimeout="20000" maxKeepAliveRequests="-1" redirectPort="8443" useComet="false" socket.appReadBufSize="87380" socket.rxBufSize="87380" socket.performanceConnectionTime="2" socket.performanceLatency="0" socket.performanceBandwidth="1" server="My server" /> 

I managed to configure most properties using bean

 @Bean public EmbeddedServletContainerFactory embeddedServletContainerFactory() { TomcatEmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory = new TomcatEmbeddedServletContainerFactory(); tomcatEmbeddedServletContainerFactory.setProtocol("org.apache.coyote.http11.Http11Nio2Protocol"); tomcatEmbeddedServletContainerFactory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { AbstractHttp11JsseProtocol<Nio2Channel> handler = (AbstractHttp11JsseProtocol)connector.getProtocolHandler(); handler.setMaxKeepAliveRequests(-1); handler.setAcceptorThreadCount(2); handler.setMaxHeaderCount(256); connector.setRedirectPort(8443); }); return tomcatEmbeddedServletContainerFactory; } 

And application.xml properties:

 server.tomcat.accept-count = 500 server.tomcat.max-threads = 600 server.port = 8080 server.max-http-header-size = 32768 server.connection-timeout = 20000 

However, I cannot figure out how to install this part.

 useComet="false" socket.appReadBufSize="87380" socket.rxBufSize="87380" socket.performanceConnectionTime="2" socket.performanceLatency="0" socket.performanceBandwidth="1" server="My server" 

Can anybody help me? thank you

+5
source share
2 answers

Try the following:

 connector.setProperty("useComet", Boolean.toString(false)); connector.setProperty("socket.appReadBufSize", "87380"); connector.setProperty("socket.rxBufSize", "87380"); connector.setProperty("socket.performanceConnectionTime", "2"); connector.setProperty("socket.performanceLatency", "0"); connector.setProperty("socket.performanceBandwidth", "1"); connector.setProperty("server", "My server"); 
+3
source
 connector.setProperty("socket.appReadBufSize", "87380"); connector.setProperty("socket.rxBufSize", "87380"); connector.setProperty("socket.performanceConnectionTime", "2"); connector.setProperty("socket.performanceLatency", "0"); connector.setProperty("socket.performanceBandwidth", "1"); connector.setProperty("server", "My server"); 

Worked great. However, it is important to check the return value of connector.setProperty. It tries to find the correct method to call for each property and returns true if the method was found and the property was set. Unfortunately, connector.setProperty("useComet", Boolean.toString(false)); does not work and returns false.

+1
source

Source: https://habr.com/ru/post/1269273/


All Articles