Question

We have a server that using embedded tomcat to accept http request.

When we shut down our server we want to:

1) Block all incoming request

2) Wait for already accepted request to finish successfully before stop the tomcat engine

After some testing, #1 is doable by stop the connector.

For #2 we tried to stop tomcat engine, but looks like it doesn't wait for the existing request to finish.

Any ideas about how to do #2?

Was it helpful?

Solution

Stopping the connector is the best way to stop the handling of new requests.

The time that Tomcat allows for requests to finish processing is configurable based on the unloadDelay attribute of the context. It defaults to 2000 (milliseconds) so setting that to a higher value should allow the requests to finish.

OTHER TIPS

  1. Block all incoming request.

Add a filter to your application with a boolean to accept request, by default it accepts.

Add a ContextListener. and complete the method onContextDestroyed() add your code to modify that boolean

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top