This is a really interesting point. Lots of systems have a &quot;vetoable shutdown about to happen&quot;, &quot;non-vetoable shutdown about to happen&quot;, &quot;non-vetoable shutdown imminent&quot; set of events:<br><ul>
<li>Unix traditionally used wall(1)</li><li>Windows and OS X apps ask you &quot;Save this document before quitting?&quot;</li><li>OS X on shutdown or restart gives apps a chance to abandon or delay the shutdown</li></ul><p>
Stepping back from the immediate problem, the &quot;real&quot; solution is to have the JVM and .NET virtual machines grow up and behave like proper systems, complete with lifecycle events. Then, AMQP connections have a chance to clean up and disconnect on their own, without special action on the part of the programmer and without unduly delaying or preventing VM shutdown.<br>
</p><p>Thinking on it, lifecycle events like these are probably already present in the .NET world actually. Does anyone know where to look?</p><p>Cheers,<br>� Tony<br></p><br><div class="gmail_quote">On 16 December 2011 08:27, Simon MacMullen <span dir="ltr">&lt;<a href="mailto:simon@rabbitmq.com">simon@rabbitmq.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">We&#39;ve had this argument back and forth a bit for both the Java and .NET clients. The reason why we&#39;ve been reluctant to do this is that by making connections use daemon / background threads we encourage a situation where connections don&#39;t get properly closed when your application shuts down.<br>

<br>
So for example if your application publishes a load of messages and then exits, if we used background threads then things would appear to work but there would be no guarantee that all the messages would reach the broker.<br>

<br>
So really the right thing to do is explicitly close connections at shut down - then you know that everything you thought the connections were doing is actually done.<br>
<br>
Cheers, Simon<div><div class="h5"><br>
<br>
On 15/12/11 20:53, Eyal Post wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
We have an issue with a .net client application that creates a<br>
connection in order to publish message and caches this connection in a<br>
variable. The problem is that when the program exits, it gets stuck in<br>
memory because there is an AMQP thread that doesn�t exit.<br>
<br>
I�m not sure how the RabbitMQ threads are created but in .net there is<br>
an option to set a thread as a background thread and in this case when<br>
the application closes it will not wait for background threads to stop.<br>
Is the .net client setting the background threads it creates background?<br>
If not, can you change that?<br>
<br>
See here for more details:<br>
<a href="http://msdn.microsoft.com/en-us/library/system.threading.thread.isbackground.aspx" target="_blank">http://msdn.microsoft.com/en-<u></u>us/library/system.threading.<u></u>thread.isbackground.aspx</a><br>
<br>
Eyal Post<br>
<br>
<br>
______________________________<u></u>______________________________<u></u>__________<br>
This email has been scanned by the Symantec Email Security.cloud service.<br>
For more information please visit <a href="http://www.symanteccloud.com" target="_blank">http://www.symanteccloud.com</a><br>
______________________________<u></u>______________________________<u></u>__________<br>
<br>
<br>
<br></div></div>
______________________________<u></u>_________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.<u></u>rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/<u></u>cgi-bin/mailman/listinfo/<u></u>rabbitmq-discuss</a><span class="HOEnZb"><font color="#888888"><br>

</font></span></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<br>
-- <br>
Simon MacMullen<br>
RabbitMQ, VMware<br>
______________________________<u></u>_________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.<u></u>rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/<u></u>cgi-bin/mailman/listinfo/<u></u>rabbitmq-discuss</a><br>
</font></span></blockquote></div><br>