[rabbitmq-discuss] Daemonizing connection threads (was Re: .Net client foreground threads)
JD Conley
jdc at hive7.com
Thu Jan 7 18:39:50 GMT 2010
> At the moment there's no easy way to ask for daemon threads if you
> decide they're appropriate for your app: so maybe we should go with
> non-daemon per default, daemon per user-selectable option.
A background/daemon thread would be preferred for our situation as well.
This configurable option would be great.
In our ASP.NET applications we hook the app domain unload event and try to
complete our pending rabbit operations and close things down. Maybe
something along these lines should be recommended in the docs. Doing this
along with making the client use a background thread means you still get the
chance to cleanup and know what has and hasn't been written to the exchange,
and you also know your app will actually shutdown and not hang.
Thread.GetDomain().DomainUnload += new
EventHandler(RabbitmqAsyncCommandService_DomainUnload);
...
void RabbitmqAsyncCommandService_DomainUnload(object sender,
EventArgs e)
{
if (null != _cnn)
{
//wait for stuff to finish (up to a few seconds)...
//close the channels...
_cnn.Close();
}
}
-JD
More information about the rabbitmq-discuss
mailing list