timer
timer(options?: TimerOptions): Source<undefined>
Trigger routes at a regular interval. Produces undefined as the message body.
For a wall-clock schedule ("every weekday at 09:00"), use cron(), which understands timezones. timer() measures elapsed time, not clock time.
// Simple interval (every second)
.id('ticker')
.from(timer({ interval: 1000 }))
// Limited runs (10 times, then stop)
.id('batch-job')
.from(timer({ interval: 5000, repeatCount: 10 }))
// Start with delay
.id('delayed-start')
.from(timer({ interval: 1000, delay: 5000 }))
// Fixed rate (ignore execution time)
.id('heartbeat')
.from(timer({ interval: 1000, fixedRate: true }))
// Add random jitter to prevent synchronized execution
.id('distributed-task')
.from(timer({ interval: 1000, maxJitter: 200 }))
Options:
Headers added: Timer metadata including fired time, counter, period, and next run time