Tomcat 7 embedded cluster using spring-boot

I am developing a web application using spring-boot. And I want to group spring-boot embedded tomcat 7. I searched all day, but the answers are almost used by server.xml and apache. But the way to use server.xml on spring-boot, I could not find it. I think I need to use the configuration of several connectors, as well as the engine and so on. I do not know, this is the right way. Please show me the way.

+6
source share
2 answers

You can use a load balancer (e.g. nginx) for load balancing and Spring-session for emergency session handling.

See an example here .

+4
source

I finally found a solution. In fact, I found a blog site.

Used by Redis .

Link http://dmitrijs.artjomenko.com/2014/02/storing-sessions-in-redis-with-spring.html

My application is developed by java7, but the example uses java8.

So, I changed the code, the modified code below:

@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { TomcatEmbeddedServletContainerFactory containerFactory = (TomcatEmbeddedServletContainerFactory) container; containerFactory.addContextValves(new RedisSessionHandlerValve()); ArrayList<MyTomcatContextCustomizer> customizers = Lists.newArrayList(new MyTomcatContextCustomizer()); containerFactory.setTomcatContextCustomizers(customizers); } }; } public class MyTomcatContextCustomizer implements TomcatContextCustomizer { @Override public void customize(Context context) { context.setSessionTimeout(30); context.setManager(new RedisSessionManager() {{ setHost("127.0.0.1"); }}); } } 
+2
source

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


All Articles