-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Feature/queue pause resume #57800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
taylorotwell
merged 6 commits into
laravel:12.x
from
yousefkadah:feature/queue-pause-resume
Nov 21, 2025
Merged
Feature/queue pause resume #57800
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e45a8a6
Add Queue Pause/Resume Feature
yousefkadah 0458552
Add pause/resume methods to Queue Factory contract
yousefkadah 14cb6bf
Remove pause/resume methods from Queue Factory interface and add faca…
yousefkadah 26f15a5
feat: Implement connection-specific queue pausing and resuming with a…
yousefkadah 3133f07
formatting
taylorotwell 10e06f4
rename method
taylorotwell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <?php | ||
|
|
||
| namespace Illuminate\Queue\Console; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use Illuminate\Contracts\Queue\Factory as QueueManager; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
|
|
||
| #[AsCommand(name: 'queue:pause')] | ||
| class PauseCommand extends Command | ||
| { | ||
| /** | ||
| * The console command name. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $signature = 'queue:pause {queue : The name of the queue to pause (connection:queue format, e.g., redis:default)} | ||
| {--ttl= : The TTL for the pause in seconds (omit for indefinite pause)}'; | ||
|
|
||
| /** | ||
| * The console command description. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $description = 'Pause processing for a specific queue'; | ||
|
|
||
| /** | ||
| * The queue manager instance. | ||
| * | ||
| * @var \Illuminate\Contracts\Queue\Factory | ||
| */ | ||
| protected $manager; | ||
|
|
||
| /** | ||
| * Create a new queue pause command. | ||
| * | ||
| * @param \Illuminate\Contracts\Queue\Factory $manager | ||
| */ | ||
| public function __construct(QueueManager $manager) | ||
| { | ||
| parent::__construct(); | ||
|
|
||
| $this->manager = $manager; | ||
| } | ||
|
|
||
| /** | ||
| * Execute the console command. | ||
| * | ||
| * @return int | ||
| */ | ||
| public function handle() | ||
| { | ||
| [$connection, $queue] = $this->parseQueue($this->argument('queue')); | ||
|
|
||
| $ttl = $this->option('ttl') !== null ? (int) $this->option('ttl') : null; | ||
|
|
||
| $this->manager->pause($connection, $queue, $ttl); | ||
|
|
||
| $this->components->info("Queue [{$connection}:{$queue}] has been paused".($ttl ? " for {$ttl} seconds." : ' indefinitely.')); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /** | ||
| * Parse the queue argument into connection and queue name. | ||
| * | ||
| * @param string $queue | ||
| * @return array | ||
| */ | ||
| protected function parseQueue($queue) | ||
| { | ||
| [$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null); | ||
|
|
||
| if (! isset($queue)) { | ||
| $queue = $connection; | ||
| $connection = $this->laravel['config']['queue.default']; | ||
| } | ||
|
|
||
| return [$connection, $queue]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| <?php | ||
|
|
||
| namespace Illuminate\Queue\Console; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use Illuminate\Contracts\Queue\Factory as QueueManager; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
|
|
||
| #[AsCommand(name: 'queue:pause:list')] | ||
| class PauseListCommand extends Command | ||
| { | ||
| /** | ||
| * The console command name. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $name = 'queue:pause:list'; | ||
|
|
||
| /** | ||
| * The console command description. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $description = 'List all currently paused queues'; | ||
|
|
||
| /** | ||
| * The queue manager instance. | ||
| * | ||
| * @var \Illuminate\Contracts\Queue\Factory | ||
| */ | ||
| protected $manager; | ||
|
|
||
| /** | ||
| * Create a new queue pause list command. | ||
| * | ||
| * @param \Illuminate\Contracts\Queue\Factory $manager | ||
| */ | ||
| public function __construct(QueueManager $manager) | ||
| { | ||
| parent::__construct(); | ||
|
|
||
| $this->manager = $manager; | ||
| } | ||
|
|
||
| /** | ||
| * Execute the console command. | ||
| * | ||
| * @return int | ||
| */ | ||
| public function handle() | ||
| { | ||
| $pausedQueues = $this->manager->getPausedQueues(); | ||
|
|
||
| if (empty($pausedQueues)) { | ||
| $this->components->info('No queues are currently paused.'); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| $this->components->info('Paused Queues:'); | ||
|
|
||
| $tableData = collect($pausedQueues)->map(function ($queue) { | ||
| // Parse connection:queue format | ||
| $parts = explode(':', $queue, 2); | ||
|
|
||
| return [ | ||
| 'connection' => $parts[0] ?? '', | ||
| 'queue' => $parts[1] ?? $parts[0], | ||
| ]; | ||
| })->toArray(); | ||
|
|
||
| $this->table( | ||
| ['Connection', 'Queue'], | ||
| $tableData | ||
| ); | ||
|
|
||
| return 0; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <?php | ||
|
|
||
| namespace Illuminate\Queue\Console; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use Illuminate\Contracts\Queue\Factory as QueueManager; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
|
|
||
| #[AsCommand(name: 'queue:resume')] | ||
| class ResumeCommand extends Command | ||
| { | ||
| /** | ||
| * The console command name. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $signature = 'queue:resume {queue : The name of the queue to resume (connection:queue format, e.g., redis:default)}'; | ||
|
|
||
| /** | ||
| * The console command description. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $description = 'Resume processing for a paused queue'; | ||
|
|
||
| /** | ||
| * The queue manager instance. | ||
| * | ||
| * @var \Illuminate\Contracts\Queue\Factory | ||
| */ | ||
| protected $manager; | ||
|
|
||
| /** | ||
| * Create a new queue resume command. | ||
| * | ||
| * @param \Illuminate\Contracts\Queue\Factory $manager | ||
| */ | ||
| public function __construct(QueueManager $manager) | ||
| { | ||
| parent::__construct(); | ||
|
|
||
| $this->manager = $manager; | ||
| } | ||
|
|
||
| /** | ||
| * Execute the console command. | ||
| * | ||
| * @return int | ||
| */ | ||
| public function handle() | ||
| { | ||
| [$connection, $queue] = $this->parseQueue($this->argument('queue')); | ||
|
|
||
| if (! $this->manager->isPaused($connection, $queue)) { | ||
| $this->components->warn("Queue [{$connection}:{$queue}] is not paused."); | ||
|
|
||
| return 1; | ||
| } | ||
|
|
||
| $this->manager->resume($connection, $queue); | ||
|
|
||
| $this->components->info("Queue [{$connection}:{$queue}] has been resumed."); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /** | ||
| * Parse the queue argument into connection and queue name. | ||
| * | ||
| * @param string $queue | ||
| * @return array | ||
| */ | ||
| protected function parseQueue($queue) | ||
| { | ||
| [$connection, $queue] = array_pad(explode(':', $queue, 2), 2, null); | ||
|
|
||
| if (! isset($queue)) { | ||
| $queue = $connection; | ||
| $connection = $this->laravel['config']['queue.default']; | ||
| } | ||
|
|
||
| return [$connection, $queue]; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not need conditions here, put method already implements forever if ttl=null