Preventing client resubmission

I have a spring controller and a query matching method.

@RequestMapping(value = { "/doSomething.do" }) public ModelAndView emailToNonBelievers(){ ..... // do something which takes lot of time // send response.. return modelAndView; } 

This method takes a very long time, about an hour. (This is for the administrator, not for users. And the administrator does not need to wait an hour. Just shoot and forget, this is normal. And this is not a batch task)

But I found that the client resubmit requests at intervals of 3 minutes (observed 6 times, and I stopped the spring service).

I think because the client did not receive any response from the server.

If my guess is correct, the server should respond like "Your request has been accepted, just shut up and wait!",

But how to send a response (200 ok) before completing tasks in Spring?

Or am I missing something?

0
spring header
Nov 19 '14 at 5:14
source share
1 answer

In this situation, it is recommended to use asynchronous task processing.

Spring comes with ready-made support for it through the @Async annotation.

Consult my answer for a detailed setup for a similar request and here for the docs.

+1
Nov 19 '14 at 5:42 on
source share



All Articles