Queue Package
Failed Jobs
Track and manage failed queue jobs.
Failed Jobs
Track and manage failed queue jobs.
Failed Job Storage
Failed jobs are stored in the failed_jobs table (database driver) or tracked in Redis.
Viewing Failed Jobs
# Via Horizon dashboard
# Visit /horizon/failed
Retrying Failed Jobs
# Retry all failed jobs
pnpm exec artisan queue:retry all
# Retry specific job
pnpm exec artisan queue:retry <job-id>
Forgetting Failed Jobs
# Forget a failed job
pnpm exec artisan queue:forget <job-id>
# Forget all failed jobs
pnpm exec artisan queue:flush-failed
Programmatic Access
import { Queue } from "@lara-node/queue";
// Get failed jobs
const failed = Queue.getFailedJobs();
// Retry failed
await Queue.retryFailed(jobId);
// Forget failed
await Queue.forgetFailed(jobId);
// Flush all failed
await Queue.flushFailed();
Job Failed Callback
class ProcessPodcast extends Job {
async handle() {
// Job logic
}
async failed(error: Error) {
// Called when job fails after all retries
await Notification.send(admin, "Job failed: " + error.message);
}
}
Retry Until
Set a time limit for retries:
class ProcessPodcast extends Job {
retryUntil() {
return Date.now() + 3600000; // 1 hour from now
}
}