SpringBoot之Callable处理异步请求


/**
 * @Classname CallableController
 * @Description TODO
 * @Date 2020/11/22 17:33
 * @Created by XinHai.Ma
 */
@RequestMapping("/callable")
@RestController
public class CallableController {

    @RequestMapping(value = "/create", method = RequestMethod.GET)
    public Callable<Map<String, Object>> createData() throws RuntimeException {
        return new Callable<Map<String, Object>>() {
            @Override
            public Map<String, Object> call() throws Exception {
                Map<String, Object> result = new HashMap<>();
                result.put("code", 200);
                result.put("message", "success");
                return result;
            }
        };
    }

}

 

就这么写,处理Callable的线程池就不用配置了


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM