forked from php-amqplib/RabbitMqBundle
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathDynamicConsumerCommand.php
More file actions
40 lines (34 loc) · 1.07 KB
/
DynamicConsumerCommand.php
File metadata and controls
40 lines (34 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* DynamicConsumerCommand
*
* The context argument is passed to the consumer instance
* which can decide about the queue and routings it uses.
*
* @author Tibor Barna <tibor.barna@wiredminds.de>
*/
namespace OldSound\RabbitMqBundle\Command;
use OldSound\RabbitMqBundle\RabbitMq\DynamicConsumer;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
class DynamicConsumerCommand extends BaseConsumerCommand
{
protected function configure(): void
{
parent::configure();
$this
->setName('rabbitmq:dynamic-consumer')
->setDescription('Executes context-aware consumer')
->addArgument('context', InputArgument::REQUIRED, 'Context the consumer runs in')
;
}
protected function getConsumerService(): string
{
return 'old_sound_rabbit_mq.%s_dynamic';
}
protected function initConsumer(InputInterface $input): void
{
parent::initConsumer($input);
$this->consumer->setContext($input->getArgument('context'));
}
}