Minimum FixedDelay for Recurring Task 10 seconds? #516
Replies: 3 comments
-
The default polling interval for new jobs is 10 seconds. If you need shorter delays, you need to configure the scheduler accordingly using |
Beta Was this translation helpful? Give feedback.
-
Thanks @nicktar. That works perfectly 👍 For completeness, here's this is the version that works: val f = File("/tmp/log.txt")
val id = UUID.randomUUID().toString()
val shortIntervalTask = Tasks.recurring("my-task", FixedDelay.of(Duration.ofMillis(500)))
.execute { _: TaskInstance<*>, _: ExecutionContext? ->
"[${Instant.now()}|$id] Executed!".also {
f.appendText("$it\n")
println(it)
}
}
val scheduler = Scheduler.create(dataSource)
.pollingInterval(Duration.ofMillis(250))
.startTasks<RecurringTask<*>>(shortIntervalTask)
.threads(15)
.build()
scheduler.start() Example log (4 concurrent instances):
|
Beta Was this translation helpful? Give feedback.
-
Glad to see you sorted this out, thank you for helping @nicktar 🙏 I think it is theoretically possible to write an outside component (until implemented as a core feature) that adds a listener for scheduled executions (and polls), and trigger an early check for due when needed (via |
Beta Was this translation helpful? Give feedback.
-
Prerequisites
Expected Behavior
Using the example code below, I was expecting a task execution every 500ms.
Current Behavior
Using the example code below I can see a task execution every 10 seconds (see logs).
Steps to Reproduce the bug
Context
Logs
Code
Beta Was this translation helpful? Give feedback.
All reactions