rabbitmq / rabbitmq-erlang-client

Erlang client for RabbitMQ
https://www.rabbitmq.com/
Other
184 stars 127 forks source link

Allow default exchange on rabbit_routing_util:parse_endpoint/1 #109

Closed yjh0502 closed 6 years ago

yjh0502 commented 6 years ago

It seems that rabbit_routing_util:parse_endpoint/1 disallow exchange with empty name. Could we change it as empty exchange name refers to default exchange?

https://github.com/rabbitmq/rabbitmq-erlang-client/blob/d776a98fbba46a27869ed9ef8424b4e504b5b03c/src/rabbit_routing_util.erl#L65-L66

michaelklishin commented 6 years ago

Last time that function was changed was 6 years ago. It's something we'd have to discuss on our team. What's the use case?

yjh0502 commented 6 years ago

rabbitmq-stomp relies on rabbit_routing_util:parse_endpoint/1 for routing. As a result there's no way to send message to default exchange with stomp plugin. The problem can be fixed by either client side or plugin side. I think fixing it on client side is better because empty exchange name is actually valid.

https://github.com/rabbitmq/rabbitmq-stomp/blob/00c9fff6229a8af90339b57250b7d45ed694fda8/src/rabbit_stomp_processor.erl#L529-L533

hairyhum commented 6 years ago

@yjh0502 to send messages to default exchange, you should use the /queue/<queuename> destination as stated in the stomp plugin docs: https://www.rabbitmq.com/stomp.html This is a special case designed for default exchange. The default exchange does not work as other exchanges and routes to queues directly, that may be the reason it was designed like this.

michaelklishin commented 6 years ago

I think the reason is a lot more boring: it's pretty confusing to use an empty string as a target in a URI, so /queue/{name} was used instead. In some other cases (CLI) we use amq.default. So I think given the use case the answer here is "we should not allow empty exchange names". Thank you for bringing this up, though :)

yjh0502 commented 6 years ago

We cannot use /queue/queue-name for multiple-producer single-exclusive consumer scenario. If a consumer binds the queue with exclusive option, producers cannot push messages on the same queue.

michaelklishin commented 6 years ago

Exclusive queues are not meant to have well-known names. Use /amq/queue or a topic. This is quickly becoming mailing list material.

yjh0502 commented 6 years ago

Thanks for the comment!