<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.19088"></HEAD>
<BODY>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>In
rabbitmq-c:</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>Is there a reason that you
cannot create an exchange with the auto_delete property ==
true?</FONT></SPAN></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>Here is the source code for
the amqp_exchange_declare function:</FONT></SPAN></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<DIV><FONT face=Courier>amqp_exchange_declare_ok_t *</FONT></DIV>
<DIV><FONT face=Courier>amqp_exchange_declare(amqp_connection_state_t state,
amqp_channel_t channel, </FONT></DIV>
<DIV><FONT face=Courier><SPAN
class=439233419-06072011> </SPAN>amqp_bytes_t
exchange, amqp_bytes_t type, </FONT></DIV>
<DIV><FONT face=Courier><SPAN
class=439233419-06072011>
</SPAN>amqp_boolean_t durable,<SPAN class=439233419-06072011>
</SPAN>amqp_table_t arguments<SPAN
class=439233419-06072011>)</SPAN><BR>{<BR> amqp_exchange_declare_t
req;<BR> req.ticket = 0;<BR> req.exchange = exchange;<BR>
req.type = type;<BR> req.passive = passive;<BR> req.durable =
durable;<BR> </FONT><FONT face=Courier><STRONG>req.auto_delete = 0;<SPAN
class=439233419-06072011> // Why always
no?</SPAN><BR></STRONG> req.internal = 0;<BR> req.nowait =
0;<BR> req.arguments = arguments;</FONT></DIV>
<DIV><FONT face=Courier></FONT> </DIV>
<DIV><FONT face=Courier> return amqp_simple_rpc_decoded(state, channel,
</FONT></DIV>
<DIV><FONT face=Courier><SPAN
class=439233419-06072011>
</SPAN>AMQP_EXCHANGE_DECLARE_METHOD, </FONT></DIV>
<DIV><FONT face=Courier><SPAN
class=439233419-06072011>
</SPAN>AMQP_EXCHANGE_DECLARE_OK_METHOD, </FONT></DIV>
<DIV><FONT face=Courier><SPAN
class=439233419-06072011>
</SPAN>&req);<BR>}<BR></FONT></DIV></BLOCKQUOTE>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>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?</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>Is a temporary exchange
even a good idea?</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>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:</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px" dir=ltr>
<DIV><SPAN class=439233419-06072011><FONT face=Courier>void
Thread()</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier>{</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier> // create the
connection</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier>
// declare the primary command exchange</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier> //
declare the qrimary queue</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier> //
declare a "stop command" exchange</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier> //
declare a "stop command" queue</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier> //
bind everyone up and call basic_consume on the queues</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier>
</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier>
for(;;)</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier> {</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier> string
exchangeName;</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier> string
topicName;</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier> string
messageBody;</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier> int error =
readMessage(exchangeName, topicName, messageBody);</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier> if(error)
break;</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier> if(exchangeName ==
"stop")</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier>
break;</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier>
processMesage(messageBody);</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Courier>
}</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Courier>}</FONT></SPAN></DIV></BLOCKQUOTE>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>Note that I am having
<U>multiple threads</U> in <U>multiple executables</U> on <U>multiple
machines</U> 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.</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>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.</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>Is there a better way to
handle this shutdown logic?</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>Thanks,</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial>Lowell</FONT></SPAN></DIV>
<DIV><SPAN class=439233419-06072011><FONT face=Arial></FONT></SPAN> </DIV>
<DIV><SPAN class=439233419-06072011><FONT
face=Arial></FONT></SPAN> </DIV></BODY></HTML>