msmq stackoverflow exception
-
I am writeing windows service that makes use in MSMQ in .net 2003 in c#. I user the method beginPeek(TimeSpan) and waiting for an message to arrive the event handler look like this: private void MyPeekCompleted(Object source, PeekCompletedEventArgs asyncResult) { try { // End the asynchronous peek operation. Message m = _mq.EndPeek(asyncResult.AsyncResult); //logic to handel message mq.BeginPeek(new TimeSpan(0,1,0)); } catch(MessageQueueException e) { if (e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout) { Console.WriteLine(e.ToString()); } _mq.BeginPeek(new TimeSpan(0,1,0)); } catch(Exception ex) { // some code to handel error } after a while i get stackoverflow exception. event though no message arrives... It works fike for a couple of minuts and than crushes.. How can i solve this.. Sample code will be greate help.. im using winXP Thnks
-
I am writeing windows service that makes use in MSMQ in .net 2003 in c#. I user the method beginPeek(TimeSpan) and waiting for an message to arrive the event handler look like this: private void MyPeekCompleted(Object source, PeekCompletedEventArgs asyncResult) { try { // End the asynchronous peek operation. Message m = _mq.EndPeek(asyncResult.AsyncResult); //logic to handel message mq.BeginPeek(new TimeSpan(0,1,0)); } catch(MessageQueueException e) { if (e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout) { Console.WriteLine(e.ToString()); } _mq.BeginPeek(new TimeSpan(0,1,0)); } catch(Exception ex) { // some code to handel error } after a while i get stackoverflow exception. event though no message arrives... It works fike for a couple of minuts and than crushes.. How can i solve this.. Sample code will be greate help.. im using winXP Thnks
Hi, I have no experience in this, but I see a logical problem in your code. the MSDN example has BeginPeek as the last statement in the PeekCompleted handler. Yours has more than one BeginPeek, and they are not at the end, so if they complete before you have left the Completed handler (Console.WriteLine will take some msecs), a new one would be launched before the current one exits, consuming stack space. Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hi, I have no experience in this, but I see a logical problem in your code. the MSDN example has BeginPeek as the last statement in the PeekCompleted handler. Yours has more than one BeginPeek, and they are not at the end, so if they complete before you have left the Completed handler (Console.WriteLine will take some msecs), a new one would be launched before the current one exits, consuming stack space. Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hi, I have no experience in this, but I see a logical problem in your code. the MSDN example has BeginPeek as the last statement in the PeekCompleted handler. Yours has more than one BeginPeek, and they are not at the end, so if they complete before you have left the Completed handler (Console.WriteLine will take some msecs), a new one would be launched before the current one exits, consuming stack space. Hope this helps.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Mire over i have 2 begin peek because i have to continue waiting for a message one begin peek is in call if no exception and the other if an exception happen so they will never happen at the same time
Hi, this is my suggestion: remove the BeginPeeks you have, and put a single
mq.BeginPeek(new TimeSpan(0,1,0));
as the very last line of the PeekCompleted handler. :)Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google