Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set timeout for specific async request in Spring-boot

I have an sync endpoint defined as follows:

@PostMapping("/some/url/")
@ResponseBody
public Future<String> something(...) {
    ... do stuff ...
}

When the returned Future is not completed after 30 seconds the request is cancelled.

How can I increase the timeout for this specific endpoint (e.g. to 100 seconds)?

I only found answers for changing it for all endpoins:

  • Specify timeout for controller async method in Spring
  • Spring Long Polling with DeferredResult
like image 654
Peter Zeller Avatar asked Oct 30 '17 23:10

Peter Zeller


1 Answers

You can return WebAsyncTask that supports timeout.

From docs: For a Callable, you can use WebAsyncTask to provide a timeout value

like image 80
cdalxndr Avatar answered Oct 12 '22 15:10

cdalxndr