symfonyenqueue

Symfony - Multienviroment support for Envelope


I'm using enqueue-dev + messenger-enqueue-transport in symfony 4.3 (where I have multiple enviroments (.env)) with beanstalk.

How should I setup it so jobs from different enviroments don't get mixed in the same queue? (as beanstalk server is the same)

I run the jobs of each enviroment using:

APP_ENV=qa bin/console messenger:consume beanstalk -vvv
APP_ENV=production bin/console messenger:consume beanstalk -vvv

When I was using pheanstalk without Smyfony I just added a suffix on jobs name, but in symfony jobs are set using classes:

$message = new ReportMessage($reportUrl);
$this->bus->dispatch((new Envelope($message))->with(new DelayStamp(1000)));

(my old implementation):

$this->pheanstalk->useTube(JOB_REPORT_MESSAGE . APP_ENV)->put(json_encode($data));

I've tried:

enqueue:
    default:
        transport: '%env(resolve:ENQUEUE_DSN)%'
        client:
            router_topic: QA
framework:
   messenger:
     transports:
        beanstalk: enqueue://default?topic[name]=QA

And also:

enqueue:
    default:
        transport: '%env(resolve:ENQUEUE_DSN)%'
        client:
            default_queue: QA
            router_queue: QA
framework:
   messenger:
     transports:
        beanstalk: enqueue://default?queue[name]=QA

But then no messages are consumed by messenger:consume.


Solution

  • Both queue & topic must be set:

    config/packages/enqueue.yaml:

    enqueue:
        default:
            transport: '%env(resolve:ENQUEUE_DSN)%'
            client:
                default_queue: QA
                router_queue: QA
                router_topic: QA
    

    config/packages/messenger.yaml:

    framework:
       messenger:
        transports:
            beanstalk: enqueue://default?queue[name]=QA&topic[name]=QA