Spring Boot @Scheduled fixedDelay在不确定的时间后停止工作

时间:2019-04-24 06:40:14

标签: java spring spring-boot scheduled-tasks

我在Spring Boot应用程序中使用@scheduled fixeddelay从不同服务器获取记录。 因此,调度程序可以在2天内正常运行,但有时在3或4个小时后停止工作。

@Scheduled(fixedDelay = 5000)
public void testThread1() {

System.out.println("Scheduler is working----------------------------------------");
    String startTime = null;
    ResponseModel mResponseModel = mViewService.viewServerService("isScheduled", -1);
    if (mResponseModel != null) {
        if (mResponseModel.getStatus() == 1) {
            @SuppressWarnings("unchecked")
            ArrayList<ServerModel> serverDataList = (ArrayList<ServerModel>) mResponseModel.getMyObjectList();

            if (serverDataList.size() > 0) {

                for (int i = 0; i < serverDataList.size(); i++) {
                    ServerModel mServerModel = serverDataList.get(i);
                    if (mServerModel.getDataRequest() == 1) {
                        startTime = getLastRecordTimeDB(mServerModel);
                        String api_url = "API_URL";

                        mSingleTransitReq.request(api_url, _url, mServerModel);
                    }
                }
            } else {
                System.err.println("No Data");
            }
        } else {
            System.err.println("Error = " + mResponseModel.getMessage());
        }
    } else {
        System.err.println("Getting null while requesting for server into database ");
    }

}

需要帮助。

0 个答案:

没有答案