繁体   English   中英

调度不适用于 spring 启动微服务中的 rest 调用

[英]Scheduling not working for rest calls in spring boot microservice

我有一个 spring 启动微服务,它包含一个我需要每周日运行的方法,所以我在该方法上使用了@Scheduled 注释,并在配置 class 中使用了@EnableScheduling 注释。用@Scheduling 注释的方法调用了另一个方法,该方法又调用up a client class where response is fetched by making a rest call to a other microservice but the rest call step is not executing and it throws error when I use scheduled annotation when I trigger the method from controller it works fine but for scheduler the rest call没有发生。

请分享您的代码和您遇到的错误。 我正在分享一个示例供您参考。

@PostMapping(value = "/runWeeklyJob", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @Scheduled(cron =  "0 0 1 ? * SUN *")
    public ResponseEntity<?> runWeeklyJob() throws Exception {
        //processing
        return responseEntity;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM