Final Class Yiisoft\Queue\Command\RunCommand
| Inheritance | Yiisoft\ |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| configure() | Yiisoft\ |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| execute() | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $queueProvider | Yiisoft\ |
|
public function __construct(
private readonly QueueConsumerProviderInterface $queueProvider,
) {
parent::__construct();
}
| public void configure ( ) |
public function configure(): void
{
$this->addArgument(
'queue',
InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
'Queue name list to connect to.',
[],
)
->addOption(
'limit',
'm',
InputOption::VALUE_REQUIRED,
'Maximum number of messages to process in each queue. Default is 0 (no limits).',
0,
)
->addUsage('[queue1 [queue2 [...]]] --limit 100');
}
| protected integer execute ( \ | ||
| $input | \ |
|
| $output | \ |
|
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string[] $queueNames */
$queueNames = $input->getArgument('queue');
if ($queueNames === []) {
$queueNames = $this->queueProvider->getConsumerQueueNames();
}
/** @var string $queueName */
foreach ($queueNames as $queueName) {
$queueConsumer = $this->queueProvider->getConsumer($queueName);
$output->write("Processing queue $queueName... ");
$count = $queueConsumer->run((int) $input->getOption('limit'));
$output->writeln("Messages processed: $count.");
}
return 0;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.