-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[AmqpMessenger] Allow using the default amqp exchange #45784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thank you for this suggestion. |
👍 |
Thank you for this suggestion. |
👍 |
Thank you for this suggestion. |
Yes, this feature makes sense. |
I'm wondering if we'll need to manage this part in Symfony code as well, or if |
@d-ph also, could you elaborate if you intentionally put this in the configuration example:
I'm trying to understand if we still need to declare queues when using the default exchange or they are declared automagically when a message is sent there. |
Hi. Yes, queues still have to be declared in the configuration as usual. RabbitMQ will not create those queues automatically. In fact, one "nuisance" of using the default exchange, is that if a queue with a given name does not exist, then all messages/tasks sent to that non-existent queue will get silently ignored. So yes, I left that piece of configuration in the example above to indicate that it's still needed (at least at the time the example was written). |
We spent a few hours trying to figure out how to use the default exchange :D +1 for this idea |
I have prepared a PR and it's working, now writing tests. Let's see if we can get this one through 👍 |
Description
I would like to request that the AmqpMessenger allows using the default AMQP Exchange. I.e. a setup, where there isn't a pair of an Exchange and a Queue for each Messenger's Transport, but rather a single Exchange (the default one) and a separate Queue for each Transport.
This is already supported in AMQP, RabbitMQ and php/ext-amqp -- one just has to use the special, "well-known" Exchange name '' (an empty string) to indicate to the AMQP protocol that the default Exchange is desired to be used.
Adding this feature to AmqpMessenger requires that the AMQP Exchange is not attempted to be declared (or bound to any Queue), if its name is an empty string. In other words, the required change is minimal. Please see the before/after in the examples below.
Apart from the code change, it might be worthwhile to mention this use case in the online documentation, in the "exchange[name]" option description.
Thank you.
Example
The default AMQP Exchange is directing the queue messages to Queues based on the supplied routing key when dispatching a queue message. For this reason, it's best to use the following Messenger configuration at a minimum:
The current code always attempts to declare the Exchange. The following 2 code changes are needed to make it not do that if the exchange name is an empty string:
The text was updated successfully, but these errors were encountered: