[rabbitmq-discuss] rabbitmq-c: amqp_exchange_declare() always sets auto-delete to no

Lowell.Boggs at emc.com Lowell.Boggs at emc.com
Wed Jul 6 21:47:45 BST 2011

In rabbitmq-c:

Is there a reason that you cannot create an exchange with the auto_delete property == true?

Here is the source code for the amqp_exchange_declare function:

amqp_exchange_declare_ok_t *
amqp_exchange_declare(amqp_connection_state_t state, amqp_channel_t channel,
                      amqp_bytes_t exchange, amqp_bytes_t type,
                      amqp_boolean_t durable, amqp_table_t arguments)
  amqp_exchange_declare_t req;
  req.ticket = 0;
  req.exchange = exchange;
  req.type = type;
  req.passive = passive;
  req.durable = durable;
  req.auto_delete = 0;   // Why always no?
  req.internal = 0;
  req.nowait = 0;
  req.arguments = arguments;

  return amqp_simple_rpc_decoded(state, channel,
Is it safe for me as an application devloper to create a clone of this function that has the auto_delete property passed in?  Does the rabbitmq team have plans to change the way the underlying functions work?

Is a temporary exchange even a good idea?

I am trying to simplify the shutdown logic of a multi-threaded application.  I don't want to have to invent a way of signaling my worker threads to shut down.  Instead, I want to send them a message that they can read like normal but have a quick way of identifying that this is a shutdown command.  I am currently writing code for my threads that work like this:

void Thread()

    // create the connection
    // declare the primary command exchange
    // declare the qrimary queue
    // declare a "stop command" exchange
    // declare a "stop command" queue
    // bind everyone up and call basic_consume on the queues

        string exchangeName;
        string topicName;
        string messageBody;

         int error = readMessage(exchangeName, topicName, messageBody);

         if(error) break;

        if(exchangeName == "stop")


Note that I am having multiple threads in multiple executables on multiple machines all reading from the same primary command exchange for performance and redundancy reasons -- so I can't really use the topic to indicate shutdown.  I might want to shutdown a given executable on a given host, not the entire system.

The above logic is working fine, but when I kill a process, I have to remember to delete the exchanges because they don't have an autoDelete flag.

Is there a better way to handle this shutdown logic?


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110706/2d2621b3/attachment.htm>

More information about the rabbitmq-discuss mailing list