Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yousefkadah
Copy link

Problem

There is no way to pause a single queue in Laravel.
If you want to stop one queue, you must stop all queue workers — this halts all queues, not just the one you need to pause.


Solution

Add queue pause and resume functionality.
Workers will skip paused queues but continue processing other queues.


Queue::pause('emails');
Queue::resume('emails');
Queue::isPaused('emails');

Artisan Commands

php artisan queue:pause emails
php artisan queue:resume emails
php artisan queue:pause:list

How It Works

  • Pause status stored in cache
  • Workers check cache before processing each queue
  • Paused queues are skipped
  • Jobs remain in queue until resumed
  • Works with all queue drivers

Benefits

  • No lost jobs
  • Other queues keep working
  • Simple to use
  • No breaking changes

Example

Queue::pause('emails');
// Perform maintenance
Queue::resume('emails');

This feature provides better queue control without stopping all workers.

yousefkadah and others added 3 commits November 13, 2025 23:25
This commit introduces a new feature that allows pausing and resuming individual queues without stopping workers, providing granular control over queue processing.

Features:
- Queue::pause($queue, $ttl) - Pause a specific queue with optional TTL
- Queue::resume($queue) - Resume a paused queue
- Queue::isPaused($queue) - Check if a queue is paused
- Queue::getPausedQueues() - Get list of all paused queues

Artisan Commands:
- queue:pause {queue} - Pause a queue
- queue:resume {queue} - Resume a queue
- queue:pause:list - List all paused queues

Implementation:
- Modified Worker to skip paused queues when looking for jobs
- Uses cache to track paused queue status with configurable TTL
- Works with all queue drivers (Redis, Database, SQS, etc.)
- No jobs are lost - they remain in queue until resumed
- Fully backwards compatible with existing queue functionality

Files Modified:
- src/Illuminate/Queue/QueueManager.php
- src/Illuminate/Queue/Worker.php
- src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php

Files Created:
- src/Illuminate/Queue/Console/PauseCommand.php
- src/Illuminate/Queue/Console/ResumeCommand.php
- src/Illuminate/Queue/Console/PauseListCommand.php
- QUEUE_PAUSE_RESUME_FEATURE.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Update the Factory interface to include the new pause/resume methods.
This resolves IDE warnings and provides proper type hints for the
queue pause/resume functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@rodrigopedra
Copy link
Contributor

I have had something like this for years on a project to skip jobs after reaching an API rate limit to avoid attempting several jobs in a row.

It also allows having a worker working on more than one queue while the other one is paused/blocked (in my implementation I call it blocked).

Locally I have a custom queue driver that extends from the DatabaseQueue class and just overrides the pop method to return null while the queue is blocked.

And a job middleware to block/pause the queue when a 429 response is caught.

It will be great to have this in the framework.

Also, it is a much more generic solution than mine.

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants