[rabbitmq-discuss] DQOTD: Is publishing to an undeclared exchange ok?

Pieter de Zwart pdezwart at rubiconproject.com
Mon Nov 29 16:38:38 GMT 2010

Ah, thank you for the detailed response David, that makes much more sense.

On 11/27/10 10:25 PM, "David Wragg" <david at rabbitmq.com> wrote:

> Pieter de Zwart <pdezwart at rubiconproject.com> writes:
>> My Dumb Question Of The Day (registered) is: What is the expected behavior
>> when publishing to an exchange that has not been previously declared? It
>> seems that if I do that using the C client, the message disappears into the
>> void without so much as a peep.
> Publishing a message in AMQP is a fully asynchronous operation: The
> client sends a basic.publish method to the server, and does not wait for
> any kind of reply.  So there is no way for the amqp_basic_publish
> function to return an error in this case.
> But, the next synchronous operation you do on the channel should return
> the error.
> For example, with the amqp-publish utility in the rabbitmq-c tools
> directory, if you do:
>   $ tools/amqp-publish -e nosuch -b "hello"
> It responds with the error:
>   closing channel: server channel error 404, message: NOT_FOUND - no
>   exchange 'nosuch' in vhost '/'
> As the prefix to this error suggests, the error is being reported from
> amqp_channel_close, because in publish.c, that is the synchronous
> operation following the amqp_basic_publish call.
>> The only reason I ask is that I wan the PHP client to behave in the most
>> appropriate manner, matching that of the client and broker.
> Currently, if you want to get localize errors to particular
> amqp_basic_publish calls, you'll need to follow each one with a
> synchronous operation to collect the error.  Opening and closing a
> channel around each publish is perhaps the most obvious way to do this.
> David

More information about the rabbitmq-discuss mailing list