配置

spring.mvc.async.request-timeout=20000

代码

@GetMapping("test")
    public String test(){

        try {
            Thread.sleep(60000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("keep going");
        return "success";
    }

    @GetMapping("test2")
    public Callable<String> test2() {
        return ()-> {
            try {
                Thread.sleep(60000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("keep going");
            return "foobar";
        };
    }

解析

test不生效  test2生效

看看解释,异步请求到达之前的时间量 

当20秒到了,程序睡眠中断。实际就是程序直接跳出

返回503 

 

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐