How do you set both port and thread pool using embedded jetty, v 9.1.0

后端 未结 4 2321
猫巷女王i
猫巷女王i 2021-02-20 00:09

I\'m using jetty 9.1.0, embedded, and would like to set both port and ThreadPool. I see a constructor for each, but don\'t see how to use one of those, and then any way to set t

相关标签:
4条回答
  • 2021-02-20 00:21

    You could go with XML configuration from /etc/jetty.xml file, which is well documented and also use beans with Spring configuration.

    There's no constructor that will take ThreadPool and port together.

    0 讨论(0)
  • 2021-02-20 00:23
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMaxThreads(500);
    
    Server server = new Server(threadPool);
    
    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
    http.setPort(81);
    
    server.addConnector(http);
    
    0 讨论(0)
  • 2021-02-20 00:25
        Server server = new Server(new QueuedThreadPool(128, 8));
        ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory());
    
        connector.setPort(8897);
        server.addConnector(connector);
    
    0 讨论(0)
  • 2021-02-20 00:31

    I can't test it right know, but I assume you can

    a) Use a configuration file and load it

    or

    b) Use the QueuedThreadPool and do the following:

     SelectChannelConnector connector = new SelectChannelConnector();
     connector.setPort(9090);
     server.addConnector(connector);
    
    0 讨论(0)
提交回复
热议问题