简体   繁体   中英

Spring scheduler running twice

I deployed the application in JBoss with master and slave due to which my scheduler running twice. ShedLock is not solution for my problem as the email will triger till user deactivate the expired Asset. So I though of checking the request is from master or slave and based on it I will run my code, any idea how to figure it or any other solution. Thank you I am using Spring 4.x and REST web-service with MySQL db.

@Scheduled(cron = "${scheduler.i18n.crontime}")
public void getAssetNotification() {
    try {
        notificationDao.getAssetNotification(null);
    } catch (Exception e) {
        logger.error("getAssetNotification() - error in getAssetNotification", e);
    }
}

Couldn't you just do a synchronization over database?

I found an older code snippet using an aspect:

Spring Scheduled Task running in clustered environment

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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