@@ -23,8 +23,10 @@ class StaticMessageUpdateCronJob(
2323 private val staticMessageService : StaticMessageService ,
2424 private val metricService : MetricService ,
2525):ApplicationRunner {
26+ private final val intervalMinutes = Config .TIMING_STATIC_MESSAGE_UPDATE_TASK_RUN_INTERVAL_MINUTES .getLong().asMinutes()
27+
2628 override fun run (args : ApplicationArguments ) {
27- Flux .interval(Config . TIMING_STATIC_MESSAGE_UPDATE_TASK_RUN_INTERVAL_MINUTES .getLong().asMinutes() )
29+ Flux .interval(intervalMinutes )
2830 .onBackpressureDrop()
2931 .flatMap { doUpdate() }
3032 .onErrorResume { Mono .empty() }
@@ -38,11 +40,11 @@ class StaticMessageUpdateCronJob(
3840 try {
3941 val messages = staticMessageService.getEnabledStaticMessagesForShard(getShardIndex(), getShardCount())
4042 // We have no interest in updating the message so close to its last update
41- .filter { Duration .between(Instant .now(), it.lastUpdate).abs().toMinutes() >= 30 }
43+ .filter { Duration .between(Instant .now(), it.lastUpdate).abs() >= intervalMinutes.minusMinutes( 1 ) }
4244 // Only update messages in range
4345 .filter {
44- Duration .between(Instant .now(), it.scheduledUpdate).toMinutes() <= 60
45- || (it.forcedUpdate != null && Duration .between(Instant .now(), it.forcedUpdate).toMinutes() <= 60 )
46+ Duration .between(Instant .now(), it.scheduledUpdate) <= intervalMinutes
47+ || (it.forcedUpdate != null && Duration .between(Instant .now(), it.forcedUpdate) <= intervalMinutes )
4648 }
4749
4850 LOGGER .debug(" StaticMessageUpdateCronJob | Found ${messages.size} messages to update for shard ${getShardIndex()} " )
0 commit comments