user833418
user833418

Reputation: 41

multiple instances of embedded jetty

I run an embedded jetty from eclipse using maven build configuration (jetty:run). The server starts properly:

2011-07-07 13:48:11.915:INFO::Started [email protected]:8080 STARTING

[INFO] Started Jetty Server

[INFO] Starting scanner at interval of 10 seconds

Afterwards, I startup another instance listening to the same port (8080). It started properly as well. How does it possible that several instances simultaneously running and listening to the same port? BTW, my web application works fine and all the requests are going to the first instance, after shutting it down, the requests are following to the second instance. Thanks

Upvotes: 4

Views: 1480

Answers (1)

skaffman
skaffman

Reputation: 403591

This is the behaviour of the SelectChannelConnector, which uses java.nio selectors instead of java.net.Socket. I'm not sure how or why two instances are allowed to "listen" to the same port (I'm not even sure if "listen" is the right word to use for java.nio). The behaviour you're seeing is consistent, though - the second SelectChannelConnector will start receiving the messages after the first one has stopped.

You can reproduce the "traditional" behaviour by replacing SelectChannelConnector with SocketConnector.

Upvotes: 3

Related Questions