0

我有一个 Spring Boot 应用程序,我已经使用 jhispter 生成了该应用程序,我有一个具有如下预定方法的 Spring 服务:

@Scheduled(cron = "0 0/2 * * * *")
private void checkStatusRouters() {

    if(!IS_JOB_RUNNING){
        IS_JOB_RUNNING =true;
        log.info("[JOB-MONITOR] - Initializing scan", Instant.now());
        List<MicroTikRouter> routers = routerService.findAllEntities();
        log.info("Roteadores encontrados: {}",routers.size());
        for (MicroTikRouter router : routers) {
            try {
                log.info("Iniciando roteador : {}", router.getDescription());
                CompletableFuture<Boolean> check =  routerService.checkRouterStatusAsync(router);
                check.exceptionally(exception -> {
                    //HandleException
                });
            }
            catch(Exception ex){
                //Handle
            }
        }
}   }

此方法多次调用routerService.checkRouterStatusAsync(),如下所述。(我不需要等待这个方法的结果)

@Async
public CompletableFuture<Boolean> checkRouterStatusAsync(MicroTikRouter router) throws  ApiConnectionException,ApiCommandException,Exception {

    //neither this log is appearing
    log.info("Request print router {} : with ip/dns  {} ",router.getCode(),router.getIp());

    //make many things  

    return CompletableFuture.completedFuture(true);
}   

奇怪的是,该方法checkRouterStatusAsync的任何内容都没有出现在日志中。

这只发生在我的生产服务器上,它在本地有效。在双方(本地和生产中),我都安装了 Java 8。

我使用命令运行我的应用程序java -jar {myPackage}.war

任何人都可以帮助我吗?

4

0 回答 0