我需要启动一个SpringBoot异步进程,并在进程正在执行时将HTTP.202返回给客户端,而不必等待进程完成。需要它的Java代码。
例如
@RequestMapping(value ="/doSomething", method = RequestMethod.POST)
public ResponseEntity<Object> doSomething() throws Exception {
//Start asynchronous process- Need this part of the code
asynchronous();
return new ResponseEntity<Object>("Submitted for
processing",HttpStatus.ACCEPTED);
}
private void asynchronous(){
//I am going to run longer than the client can wait
}