When upgrading the web service of java, how can I ensure that the request in progress can be completed properly?

java"s web service is deployed on linux. When upgrading a new version of kill-9 XXXX, some unprocessed requests are aborted, especially some operations to write to the database.
is there any way to stop service after the current request is successfully completed?

Note: procedure for upgrading the service version :

  1. stop the old version of the service (kill-9 xxxxx)
  2. start a new service.
Mar.03,2021

all web servers have a normal stop function. What do you mean by kill-9?

do you just unplug the computer when you turn it off?


if there is something similar to nginx between your service and users, directly change the nginx configuration, direct the service to an upgrade prompt page, make sure that no new requests come in, and then shut down the service directly after all the old requests have been processed. If the service is directly connected to the user, you can change the dns. Of course, the safest way is to change the code of the service, use something like a global variable as a tag, and then the administrator changes the tag when upgrading. Once the service detects that the tag has been changed, it rejects the new request, but continues to process the old request.

Menu