Jetty nonblocking by default?

安稳与你 提交于 2019-12-23 18:07:45

问题


Please tell me, Is Jetty non-blocking web server by default or not?

For example, this code below runs Jetty as non-blocking web server?

Server server = new Server(8080);

ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

context.setContextPath("/");

server.setHandler(context);

context.addServlet(new ServletHolder(new MyServlet()),"/*");

server.start();

server.join();

Thank you!!!


回答1:


It depends on which version of Jetty you're using.

  • In Jetty 6, the "Server(int port)" constructor would open a blocking connector on that port.
  • In Jetty 7, the "Server(int port)" constructor opens a non-blocking connector on that port.

If you really care about the behaviour, you're better off configuring the connector yourself, rather than relying on that convenience constructor.



来源:https://stackoverflow.com/questions/4156420/jetty-nonblocking-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!