I am using deferredResult
on Spring MVC, but using this code, the timeout still are sending back the HTTP code 503 to the client.
future.onCompletion(new Runnable() {
@Override
public void run() {
if(future.isSetOrExpired()){
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
}
}
});
Any idea what else to try?
I ran into the same issue. My Spring MVC Controller method originally returned DeferredResult<Object> but then I realised I wanted to control the HTTP status code. I found the answer here:
http://www.jayway.com/2014/09/09/asynchronous-spring-service/
Just use DeferredResult<ResponseEntity> and you can set both the response and the Http response code in the ResponseEntity.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.