prolic / HumusAmqp

PHP 7.4 AMQP library
https://humusamqp.readthedocs.io/
MIT License
76 stars 17 forks source link

direct exchanges and messageName filters #17

Closed basz closed 8 years ago

basz commented 8 years ago

I am beginning to suspect that for direct exchanges the # and * notations do not apply.

I have been experimenting a bit and whatever I try messages won't get passed from the exchange the queue unless I manually add the messageNames to the binding.

Currently AmqpMessageProducer:78 used the $messageName which (in my case) resolves to FQCN. I have replaced any \ with a dot. I've lowercased them. But unless I manually add the exact FQCN to the binding nothing happens. I would need add every Command then manually...

I can't find anything referring to # or * in the context of a direct exchange type. Everybody seems to write 'around' that.

eg. https://www.cloudamqp.com/blog/2015-09-03-part4-rabbitmq-for-beginners-exchanges-routing-keys-bindings.html

Can I ask what the reason is for messageNames? I presume all messages send via the utilised producer should go to the same queue anyway? If you don't want that you can add a second producer configuration?

prolic commented 8 years ago

If you want to use a direct exchange, you have to configure the exact routing key. To use '#' as routing key, use a topic exchange.

I presume all messages send via the utilised producer should go to the same queue anyway? - That's a false assumption. The producer only sends a message to an exchange and does not know about any queues at all. The routing between exchanges and queues is independent of the producer. So you could have a distinct queue handling specific commands and another queue handling other commands, both coming from the same exchange.

basz commented 8 years ago

I've now added al my Command Names as routing keys. The direct exchange now works as expected.