Created
August 26, 2019 06:42
-
-
Save lotabout/fb02706c9cb210426c259d2475fb5a70 to your computer and use it in GitHub Desktop.
How to add an additional connector in spring boot's application?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.catalina.connector.Connector; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.boot.builder.SpringApplicationBuilder; | |
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; | |
import org.springframework.boot.web.servlet.server.ServletWebServerFactory; | |
import org.springframework.context.annotation.Bean; | |
@SpringBootApplication | |
public class SpringApplication { | |
public static void main(String[] args) { | |
new SpringApplicationBuilder(SpringApplication.class).run(); | |
} | |
@Bean | |
public ServletWebServerFactory servletContainer() { | |
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); | |
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); | |
connector.setPort(8081); | |
tomcat.addAdditionalTomcatConnectors(connector); | |
return tomcat; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Say your main thread is blocking waiting for another service's callback. And the max worker thread number is 200. Then say
So that your whole system is dead lock.
Thus we need to preserve some threads for our callback endpoint/controller.
The only way that I found is to create another connector(with another port) for the callback.