spring-boot-scheduling
Installation
SKILL.md
Spring Boot Scheduling Standards
Priority: P0
Implementation Guidelines
Scheduled Tasks
- ThreadPool: ALWAYS configure a dedicated
TaskScheduler(default is 1 thread). Enable with@EnableSchedulingannotation. - Async: Keep
@Scheduledmethods light; offload to@Async/Queues. Wrap logic in try/catch; log errors and use@Retryablefor retry on transient failures.
Distributed Locking (ShedLock)
- Problem:
@Scheduledruns on ALL pods in K8s. - Solution: Use ShedLock to guarantee single execution.
- Config: Set
lockAtMostFor(deadlock safety) andlockAtLeastFor(debounce).