Queue Commands Reference
Complete reference for all queue-related Artisan commands in the Volare application.
Custom Commands
Section titled “Custom Commands”queue:test
Section titled “queue:test”Dispatch a test job to verify queue functionality.
./vendor/bin/sail artisan queue:testWhat it does:
- Dispatches a
TestQueueJobwith a test message - Confirms job was queued successfully
- Provides next steps for monitoring
queue:monitor
Section titled “queue:monitor”Display current queue status and pending jobs.
./vendor/bin/sail artisan queue:monitorExample Output:
Queue Status:Pending jobs: 5Failed jobs: 0Pro tip: Use with watch for live monitoring:
watch -n 2 './vendor/bin/sail artisan queue:monitor'Laravel Queue Commands
Section titled “Laravel Queue Commands”queue:work
Section titled “queue:work”Start processing jobs on the queue.
./vendor/bin/sail artisan queue:work [connection] [options]Important Options:
| Option | Description |
|---|---|
--queue= | Queues to process (comma-separated, priority order) |
--once | Process single job then exit |
--stop-when-empty | Stop when queue is empty |
--sleep= | Seconds to sleep when no jobs available (default: 3) |
--tries= | Number of times to attempt a job (default: 1) |
--timeout= | Maximum seconds a job should run (default: 60) |
--max-time= | Maximum seconds worker should run |
--max-jobs= | Maximum jobs to process before stopping |
--memory= | Memory limit in MB (default: 128) |
Examples:
# Default queue worker (used in docker-compose.yml)./vendor/bin/sail artisan queue:work --sleep=3 --tries=3 --max-time=3600
# Process specific queue with priority./vendor/bin/sail artisan queue:work --queue=high-priority,default
# Process one job and exit./vendor/bin/sail artisan queue:work --oncequeue:listen
Section titled “queue:listen”Listen to a queue and process jobs (with code reload).
./vendor/bin/sail artisan queue:listen [connection] [options]Difference from queue:work:
- Restarts framework on each job (slower but picks up code changes)
- No need to manually restart after code changes
- Not recommended for production
queue:restart
Section titled “queue:restart”Signal all queue workers to restart after current job.
./vendor/bin/sail artisan queue:restartWhen to use:
- After deploying code changes
- After config changes
- After dependency updates
queue:retry
Section titled “queue:retry”Retry failed jobs.
./vendor/bin/sail artisan queue:retry [id]Examples:
# Retry all failed jobs./vendor/bin/sail artisan queue:retry all
# Retry specific failed job./vendor/bin/sail artisan queue:retry 9e3e9e3e-9e3e-9e3e-9e3e-9e3e9e3e9e3e
# Retry jobs from specific queue./vendor/bin/sail artisan queue:retry all --queue=paymentsqueue:forget
Section titled “queue:forget”Delete a failed job.
./vendor/bin/sail artisan queue:forget [id]queue:flush
Section titled “queue:flush”Delete all failed jobs.
./vendor/bin/sail artisan queue:flushWarning: Use with caution in production!
queue:failed
Section titled “queue:failed”List all failed jobs.
./vendor/bin/sail artisan queue:failedGet detailed info:
./vendor/bin/sail artisan tinker>>> $failed = DB::table('failed_jobs')->latest()->first();>>> echo $failed->exception;queue:clear
Section titled “queue:clear”Delete all jobs from a queue.
./vendor/bin/sail artisan queue:clear database --queue=emailsqueue:prune-failed
Section titled “queue:prune-failed”Prune stale failed jobs.
# Prune jobs older than 24 hours (default)./vendor/bin/sail artisan queue:prune-failed
# Prune jobs older than 7 days./vendor/bin/sail artisan queue:prune-failed --hours=168queue:prune-batches
Section titled “queue:prune-batches”Prune stale batch records.
./vendor/bin/sail artisan queue:prune-batches --hours=720Common Workflows
Section titled “Common Workflows”Development Workflow
Section titled “Development Workflow”# 1. Start development environment./vendor/bin/sail up -d
# 2. Verify queue is working./vendor/bin/sail artisan queue:test
# 3. Monitor queue status./vendor/bin/sail artisan queue:monitor
# 4. Make code changes to jobvim app/Jobs/ProcessPayment.php
# 5. Restart workers to pick up changes./vendor/bin/sail artisan queue:restart
# 6. Test your job./vendor/bin/sail artisan tinker>>> ProcessPayment::dispatch($orderId, 'credit_card');
# 7. Watch logs./vendor/bin/sail artisan tailDebugging Failed Jobs
Section titled “Debugging Failed Jobs”# 1. List all failed jobs./vendor/bin/sail artisan queue:failed
# 2. Get detailed error information./vendor/bin/sail artisan tinker>>> $failed = DB::table('failed_jobs')->latest()->first();>>> echo $failed->exception;
# 3. Fix the underlying issue in code
# 4. Restart workers./vendor/bin/sail artisan queue:restart
# 5. Retry the failed job./vendor/bin/sail artisan queue:retry allProduction Deployment
Section titled “Production Deployment”# 1. Deploy new codegit pull origin main
# 2. Install dependenciescomposer install --no-dev --optimize-autoloader
# 3. Run migrationsphp artisan migrate --force
# 4. Clear and rebuild cachephp artisan config:cachephp artisan route:cachephp artisan view:cache
# 5. Restart queue workers gracefullyphp artisan queue:restart
# 6. Monitor queue healthphp artisan queue:monitorEmergency Procedures
Section titled “Emergency Procedures”Queue is Stuck:
# 1. Check what's in the queue./vendor/bin/sail artisan queue:monitor
# 2. Check worker statusdocker ps | grep queue
# 3. Restart worker container./vendor/bin/sail restart queue
# 4. If still stuck, clear queue (CAUTION!)./vendor/bin/sail artisan queue:clear database --queue=defaultToo Many Failed Jobs:
# 1. Investigate cause./vendor/bin/sail artisan tinker>>> DB::table('failed_jobs')->latest()->first()->exception;
# 2. Fix underlying issue
# 3. Retry if fixable./vendor/bin/sail artisan queue:retry all
# 4. Or flush if not recoverable./vendor/bin/sail artisan queue:flushQuick Reference Card
Section titled “Quick Reference Card”# Testing & Monitoringqueue:test # Dispatch test jobqueue:monitor # Show queue statusqueue:failed # List failed jobs
# Worker Managementqueue:work # Start processing (in Docker)queue:restart # Gracefully restart workers
# Failed Job Managementqueue:retry all # Retry all failed jobsqueue:retry {id} # Retry specific jobqueue:forget {id} # Delete failed jobqueue:flush # Delete all failed jobs
# Maintenancequeue:clear # Clear pending jobsqueue:prune-failed # Remove old failed jobsqueue:prune-batches # Remove old batch records
# Logging & Debuggingartisan tail # Follow Laravel logslogs queue # View worker logs (Sail)tinker # Interactive consoleRelated Documentation
Section titled “Related Documentation”- Queue System - Queue infrastructure
- Creating Jobs Guide - How to create queue jobs