Suppose we have a spring rest controller that does a long operation:
@PostMapping(path = "someLongOperation")
public ResponseEntity<?> doOp(@RequestBody MyBody) {
...do A
...do B //client cancels request while execution is at this step
...do some calculations
...save result to database
return ResponseEntity.ok("my response body")
}
And at step B client cancels the request, eg. pressing cancel on Postman, closing web page on browser, will our method still continue executing and write the results to the database?
And are asynchronous methods different in this regard?
@PostMapping(path = "someLongOperation")
public Callable<ResponseEntity<?>> doOp(@RequestBody MyBody) {
return () -> {
...do A
...do B //client cancels request while execution is at this step
...do some calculations
...save result to database
return ResponseEntity.ok("my response body")
}
}