Clean up queue if exchange doesn't exist
Summary:
When the API client calls /delivery/register_consumer, a queue is
first created, then bound to an exchange.
If the exchange doesn't exist, the queue has been created but is
unused. If we check the exchange exists through a passive exchange
declaration, we always introduce an extra call to the broker.
It's so probably faster to delete queue afterwards when this occurs.
Test Plan:
Post the following payload to /delivery/register_consumer:
{ "exchange": "notexisting" }
Get the following output to the console:
Deleting unused queue: delivery-020ea9cd-08c8-4029-83e2-28e21039c3cb 127.0.0.1 - - [06/Jul/2017 22:00:03] "POST /delivery/register_consumer HTTP/1.1" 400 - Channel error: (404, "NOT_FOUND - no exchange 'notexisting' in vhost 'test'")
Queue wasn't present in the broker administration panel.
Reviewers: dereckson
Reviewed By: dereckson
Differential Revision: https://devcentral.nasqueron.org/D999