achilleasa / dart_amqp

Dart AMQP client implementing protocol version 0.9.1
MIT License
79 stars 40 forks source link

Publishing on default exchange? #86

Closed mmaschenk closed 2 years ago

mmaschenk commented 2 years ago

Hi. I tried to use your library to put a message on the default exchange (which by convention has the empty string as a name) of my server. However, your code does not allow for this (line 547 of client/impl/channel_impl.dart deliberately throws an exception).

Is there a reason the library does not allow this, and is there any other way to publish on the default exchange?

Thanks.

achilleasa commented 2 years ago

That is intentional.

As per the exchange section of the spec:

- The server MUST NOT allow clients to access the default exchange except by specifying an empty exchange name in the Queue.Bind and content Publish methods. 

Even if you allow the request to proceed (e.g. change the check to if (name.isEmpty && type != ExchangeType.DIRECT){ , rabbitmq would most likely reject the request with an error similar to ACCESS_REFUSED - operation not permitted on the default exchange.

You can find more information about how the default direct exchange works here.