Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Messenger][AQMP] Setup is called every time accessing the queue #32172

Copy link
Copy link
Closed
@aurimasniekis

Description

@aurimasniekis
Issue body actions

Symfony version(s) affected: All since Messenger release

Description
Messenger AMQP call setup method on each call to the queue like: get, publish, publishWithDelay.

How to reproduce

framework:
    messenger:
        transports:
             async:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                options:
                    queues:
                        '':
                            binding_keys:
                              - pubsub
                            flags: 8
                    exchange:
                        name: pubsub
                        type: fanout

I am running modified code which don't sets name if queue name is empty:

public function queue(string $queueName): \AMQPQueue
    {
        if (!isset($this->amqpQueues[$queueName])) {
            $queueConfig = $this->queuesOptions[$queueName];

            $amqpQueue = $this->amqpFactory->createQueue($this->channel());
            if ($queueName !== '') {
                $amqpQueue->setName($queueName);
            }

            $amqpQueue->setFlags($queueConfig['flags'] ?? AMQP_DURABLE);

            if (isset($queueConfig['arguments'])) {
                $amqpQueue->setArguments($queueConfig['arguments']);
            }

            $this->amqpQueues[$queueName] = $amqpQueue;
        }

        return $this->amqpQueues[$queueName];
    }

Possible Solution
Have a flag in Connection object which says that setup has run and only run if AMQP returns 404 like in

https://github.com/symfony/symfony/blob/4.4/src/Symfony/Component/Messenger/Transport/AmqpExt/Connection.php#L321

Additional context
I am working on implementing pubsub on AMQP and getting into issues that with the random queue name messenger tries to call declareQueue on each call which leads to 403 because you can't define queue with amq.* prefix in normal cases it's alright as it just redefines it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.