簡體   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