Closed
Description
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
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.