Вопрос

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?

Это было полезно?

Решение

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.

Другие советы

  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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top