'Set queue name from parameters in symfony 3.4 and enqueue-bundle 0.9.13

This is my Symfony 3.4 configuration for php-queue bundle 0.9.13:

parameters.yml:

enqueue_dsn: 'amqp+lib://192.168.32.1'

services.yml:

messages_processor:
    class: 'InteroperabilityBundle\Processor\MessagesProcessor'
    tags:
      - { name: 'enqueue.transport.processor', processor: 'manager_tasks_processor' }

MessagesProcessor.php:

class MessagesProcessor implements Processor, CommandSubscriberInterface, QueueSubscriberInterface
{

    public function process(Message $message, Context $context)
    {
        // do something ...
    }

    public static function getSubscribedCommand(): array
    {
        return [
            'command' => 'newMessageFromApi',
            'processor' => 'manager_tasks_processor',
            'queue' => 'manager_tasks',
            'prefix_queue' => false,
            'exclusive' => false,
        ];
    }

    public static function getSubscribedQueues(): array
    {
        return ['manager_tasks'];
    }
}

And my command to start processor:

bin/console enqueue:transport:consume manager_tasks_processor manager_tasks --time-limit=3600

In the test environment this works. However now I need to specify a queue with a different name for production. And have another one in the testing environment (both on the same VPS).

How can I achieve this? The name of the queue is handcoded, in a static method. How can I get that name from the parameters?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source