Skip to content

[Messenger] AMQP Transport creates a queue based on the exchange name if no queues are configured #39652

Closed
symfony/symfony-docs
#16689
@leroy0211

Description

@leroy0211

Symfony version(s) affected: 4.4.*

Description
In \Symfony\Component\Messenger\Transport\AmqpExt\Connection.php when you don't configure any queue name, it uses the exchange name to create a queue.

Use Case (with RabbitMQ):

We have a microservice application that only needs to send out messages to an exchange. And let other microservice applications read those messages. Those other microservices can be symfony, but that doesn't matter.
Out consumer microservices create and manage their queue's. That means that the producer will send messages to some exchange and when no consumer is listening, those messages are gone. That's fine.

The problem is that when we run the producer microservice, it automatically creates a queue with the same name as the exchange. Because that's what that Connection.php class is doing.

We also don't want to use the auto_setup: false, because we believe that the producer is responsible to create the right exchange.

We have a workaround, where we have configured the queues property to be an empty array. Because then we can trick messenger to not create any queue's.

How to reproduce

#messenger.yaml
framework:
    messenger:
        transports:
            async:
                dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
                options:
                    # hack: We trick messenger here to not create queues
                    queues: []
            sync: 'sync://'

#.env.local
MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/my_exchange_name

Additional context

This application does not have any handlers, it only produces messages which need to be distributed to other applications.

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