Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Embedded jetty with 2 connectors and two DispatcherServlets

That was it!  Thank you very much!

On Tuesday, January 21, 2025 at 06:29:03 PM GMT+3, Joakim Erdfelt <joakim.erdfelt@xxxxxxxxx> wrote:



On Tue, Jan 21, 2025 at 5:22 AM jdison16--- via jetty-users <jetty-users@xxxxxxxxxxx> wrote:
Hello!

I am writing a Java application using embedded Jetty server.
I need it to listen on two different ports (one for public API calls, another for private API), and each
port serving different set of API calls.

Can you please help me how to achieve this?

Right now I have the following excerpt of code configuring a single Connector:

QueuedThreadPool qtp = new QueuedThreadPool(maxThreads, 8, 60000, new BlockingArrayQueue<>(maxQueueLength));
Server jetty = new Server(qtp);

ServerConnector connector = new ServerConnector(jetty);
connector.setPort(port);
jetty.setConnectors(new Connector[]{connector});

ServletHolder servletHolder = new ServletHolder(dispatcherServlet);
ServletContextHandler context = new ServletContextHandler(null, "/", ServletContextHandler.SESSIONS);
context.addServlet(servletHolder, path);

StatisticsHandler statisticsHandler = new StatisticsHandler();
statisticsHandler.setHandler(context);
jetty.setHandler(statisticsHandler);

return jetty;

So I want to configure seconds Connector here and make it serve only requests from another dispatcherServler2.

Thanks in advance!
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/jetty-users

Back to the top