0 follower

Final Class Yiisoft\Queue\Command\RunCommand

InheritanceYiisoft\Queue\Command\RunCommand » Symfony\Component\Console\Command\Command

Protected Methods

Hide inherited methods

Method Description Defined By
execute() Yiisoft\Queue\Command\RunCommand

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Queue\Provider\QueueProviderInterface $queueProvider )
$queueProvider Yiisoft\Queue\Provider\QueueProviderInterface

                public function __construct(
    private readonly QueueProviderInterface $queueProvider,
) {
    parent::__construct();
}

            
configure() public method

public void configure ( )

                public function configure(): void
{
    $this->addArgument(
        'queue',
        InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
        'Queue name list to connect to.',
        $this->queueProvider->getNames(),
    )
        ->addOption(
            'maximum',
            'm',
            InputOption::VALUE_REQUIRED,
            'Maximum number of messages to process in each queue. Default is 0 (no limits).',
            0,
        )
        ->addUsage('[queue1 [queue2 [...]]] --maximum 100');
}

            
execute() protected method

protected integer execute ( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output )
$input \Symfony\Component\Console\Input\InputInterface
$output \Symfony\Component\Console\Output\OutputInterface

                protected function execute(InputInterface $input, OutputInterface $output): int
{
    /** @var string $queue */
    foreach ($input->getArgument('queue') as $queue) {
        $output->write("Processing queue $queue... ");
        $count = $this->queueProvider
            ->get($queue)
            ->run((int) $input->getOption('maximum'));
        $output->writeln("Messages processed: $count.");
    }
    return 0;
}