longPolling-demo
longPolling-demo copied to clipboard
the action of return response should be locked
In ConfigServer
addListener method:
if (asyncTask.isTimeout()) {
dataIdContext.remove(dataId, asyncTask);
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); // action1
asyncContext.complete();
}
publishConfig method:
response.setStatus(HttpServletResponse.SC_OK); // action2
response.getWriter().println(configInfo);
asyncTask.getAsyncContext().complete();
if action1 and action2 happen at the same time, maybe return a response with 200 status code and blank configInfo.