質問

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