fun executeTaskWithBackOff(executor: ScheduledExecutorService = Executors.newScheduledThreadPool(1), maxAttempts: Int? = null, initialRetryDelayMillis: Long, taskDescription: String, ctx: <ERROR CLASS>, task: () -> Unit): Unit
Attempts a single execution of the given task, and retrying with an exponential backoff strategy if execution fails. An error is logged upon every failure but no exceptions are thrown.
executor
- Scheduled execution service used to invoke the task.
maxAttempts
- Maximum number of execution attempts of the task. Set to null to run indefinitely.
initialRetryDelayMillis
- The initial delay between the first failed execution and second attempt.
This is doubled upon every subsequent failed attempt.
taskDescription
- Human-readable description of the task (for error logging).