Spring@Scheduled with cron,如果服务在预定日期停止,我该如何处理

Spring@Scheduled with cron,如果服务在预定日期停止,我该如何处理,spring,spring-boot,kotlin,axon,Spring,Spring Boot,Kotlin,Axon,因此,假设我有一个系统,要求你在开始使用它之前增加一些平衡。因此,假设它将在每月30日扣除/支出您的余额。因此,我使用AxonFramework与spring计划注释相结合,因此代码可能如下所示 @CommandHandler @Scheduled(cron = "** cron for every 30th **") fun handle(command: ExpendNetflixUserCommand){ if (user.balance < netflixP

因此,假设我有一个系统,要求你在开始使用它之前增加一些平衡。因此,假设它将在每月30日扣除/支出您的余额。因此,我使用AxonFramework与spring计划注释相结合,因此代码可能如下所示

@CommandHandler
@Scheduled(cron = "** cron for every 30th **")
fun handle(command: ExpendNetflixUserCommand){
  if (user.balance < netflixPackage.price){
    AggregateLifecycle.apply(command.toNetflixUserDisabled())
    throw IllegalArgumentException("Insufficient balance, please add.")
  }
  AggregateLifecycle.apply(command.toNetflixUserExpended())
}
@CommandHandler
@已计划(cron=“**cron每30个**”)
有趣的句柄(命令:ExpendNetflixUserCommand){
if(user.balance

所以我的问题是,如果是在30日,我的系统将要计算这些付款,但突然服务中断,它在31日重新开始工作,它是否会重新计算以前的付款?如果不是,你能建议我如何处理这个案子吗?

< P>你应该考虑依赖一个更成熟的解决方案,比如你能得到像工作状态管理这样的东西,非常重要。我可能会有一个带有
@Schedule
注释的外部组件,它将使用
CommandGateway
的实例来分派命令! 使用这种方法,该组件是代码的外部组件,并带来额外的好处。 其中一个功能是在此
CommandGateway
上配置
RetryScheduler
,它将根据需要重试失败的命令

查看ref指南了解更多关于如何操作以及Axon为您提供的现成实现的信息!