SpringBoot需要启动异步过程

时间:2019-07-16 12:32:26

标签: spring-boot asynchronous

我需要启动一个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
}

0 个答案:

没有答案