Hi Emile,<br><br>I&#39;m using a class based on Subscription (the core functionality is the same as Subscription in v2.2.0 and the only differences are that I have new methods and made public a pair of private properties) called from a RpcServer class (which I also made my own modifications but calls my custom Subscription class the same way as the v2.2.0 provided classes)<br>
<br>I can reproduce the issue (but I&#39;m not sure if it is a expected behavior) by doing the following steps:<br><br>1. Send� messages to a queue<br>2. Start a consumer application<br>3. Disable the network connection in order to simulate an unexpected crash.<br>
<br>What I see is that the my custom RpcServer class which recover� the messages keep looping with the foreach although there connection is closed.<br><br>public void MainLoop()<br>{<br>���������� <br>����������� foreach (BasicDeliverEventArgs evt in m_subscription)<br>
����������� {<br>������������������� ProcessRequest(evt);<br>����������� }<br>����������� <br>�}<br><br>In my custom Subscription class I see that the method Next is returning all events even if the consumer is not running and no exception is launched  when is called by foreach loop.<br>
(note: Next() is identical to Subscription class in v2.2.0 because I didn&#39;t modiy it)<br><br>������� public BasicDeliverEventArgs Next()<br>������� {<br>����������� try<br>����������� {<br>��������������� QueueingBasicConsumer consumer = m_consumer;<br>
��������������� if (consumer == null)<br>��������������� {<br>������������������� // Closed!<br>������������������� m_latestEvent = null;<br>��������������� }<br>��������������� else<br>��������������� {<br><br>������������������� m_latestEvent = (BasicDeliverEventArgs)consumer.Queue.Dequeue();<br>
��������������� }<br>����������� }<br>����������� catch (EndOfStreamException)<br>����������� {<br>��������������� m_latestEvent = null;<br>����������� }<br>����������� return m_latestEvent;<br>������� }<br><br><br>My question is: should consumer.Queue.Dequeue() raise an exception when &quot;consumer&quot; property IsRunning is false?<br>
Currently this is not happening.<br><br>In my code a workaround could be to check consumer.IsRunning and assign m_lastestEvent to null when if it is &quot;false&quot; and in MainLoop handle that or to launch an excepcion which <span id="result_box" class="short_text" lang="en"><span title="Haz clic para obtener traducciones alternativas" class="hps">would cause </span></span>MainLoop to end.<br>
<br>Any advice would be appreaciated.<br><br>Thank you in advance.<br><br><br>Regards,<br><br>Alfonso<br><br><br><br><br><br><br><br><div class="gmail_quote">2011/3/30 Emile Joubert <span dir="ltr">&lt;<a href="mailto:emile@rabbitmq.com">emile@rabbitmq.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Alfonso,<div class="im"><br>
<br>
On 30/03/11 15:43, Alfonso wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
<br>
This is a difficult one: I&#39;ve observed a couple of times that my<br>
consumer (.NET API 2.2.0) doesn&#39;t notice when the server that is<br>
running RabbitMQ (2.2.0) crashes.<br>
Please note that I mean server crash -unexpected shutdown, OS crash,<br>
etc.- not RabbitMQ crash.<br>
<br>
My application is consuming from a queue using &quot;foreach&quot; to get the<br>
messages and I has an event handler attached to the onShutdown event.<br>
</blockquote>
<br></div>
I&#39;m not able to reproduce this using version 2.2.0 of the broker and the .NET client, implementing the the Subscription pattern. A connectivity problem immediately causes an OperationInterruptedException to be thrown from ConnectionBase.Dispose().<div class="im">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Time ago disconnection tests consisting of disconnecting the consumer<br>
from the web admin console were made and the event handler was fired<br>
always. So disconnections are caught and logged properly.<br>
<br>
The problem is that the consumer got stuck when the server crashed and<br>
it didn&#39;t notice that the connection was gone (due to a server crash)<br>
so it was impossible to log a disconnection error.<br>
In the code there is a while loop for reconnecting when the connection<br>
fails but didn&#39;t loop because my guess is that the code were stuck in<br>
the &quot;foreach&quot;.<br>
<br>
Am I missing something or this could be and issue?<br>
</blockquote>
<br></div>
Is it possible that you are preventing an exception from the socket from affecting the Subscription? Posting a minimal piece of code for demonstration may be useful.<br>
<br>
<br>
<br>
Regards<br><font color="#888888">
<br>
Emile<br>
<br>
<br>
</font></blockquote></div><br>