【问题标题】:Spring scheduler running twiceSpring调度程序运行两次
【发布时间】:2019-01-10 12:19:55
【问题描述】:

我将应用程序部署在 具有主从属关系的 JBoss 中,因此我的调度程序运行了两次。 ShedLock 不是我的问题的解决方案,因为电子邮件将触发直到用户停用过期的资产。所以我虽然检查请求是来自主机还是从机,并基于它运行我的代码,知道如何计算它或任何其他解决方案。谢谢 我正在使用带有 MySQL db 的 Spring 4.x 和 REST Web 服务。

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

【问题讨论】:

  • 我们在主从服务器的主机文件中添加参数,如果从主服务器读取,我们将触发,否则不会触发通知。

标签: java spring-mvc jboss scheduled-tasks


【解决方案1】:

您不能只对数据库进行同步吗?

我发现了一个使用方面的旧代码 sn-p:

Spring Scheduled Task running in clustered environment

【讨论】:

  • 这是一个单一的数据库
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-09-22
  • 1970-01-01
  • 2020-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多