Strange Issue:Window Service
-
Hi All I am facing a strange issue and i am working on this issue for last one week,but i am not able to find it.I have a window service which reads the MSMQ .This windows service will do only this function.Now, when some thing is written to MSMQ, window service will read the msmq.Now there is nothing in queue ,then also it will loop and if some thing comes inside the msmq then again it will read ...this works fine if i am doing in regular intervals. Now if am not doing any operations for two or three hours ,then status of windows service will be started but it will not reading the msmq,and it is not throwing any error..also...this is the strange thing i am facing..why it is behaving like this.Can any one help me in this idea.I am pasting the start section of of mywindows service here .can any one tell me what is wrong in this code.Thanks in advance this code i am calling inside a thread.. try { MessageQueue mq = null; System.Messaging.Message msg = null; while(true) { //MessageQueue mq = null; //System.Messaging.Message msg = null; try { if(mq == null) { mq = new System.Messaging.MessageQueue (XMLReprocessMSMQPath); } RemoteLoggingManager.LogMessage(LoggingMessageTypes.Error, APPLICATIONNAME,"Read Queue", LoggingMessageTargets.Both); msg = mq.Receive(new TimeSpan(0,0,0,10,0)); RemoteLoggingManager.LogMessage(LoggingMessageTypes.Error, APPLICATIONNAME,"Data Rec", LoggingMessageTargets.Both); msg.Formatter = new ActiveXMessageFormatter(); XMLReprocessMSMQFileName=ReceiveMessage(msg.Body.ToString()); SendXMLToWebervice(XMLReprocessMSMQFileName); } catch (System.Messaging.MessageQueueException ex) { if(ex.ErrorCode != -2147467259) // Ignore timeout error { RemoteLoggingManager.LogMessage(LoggingMessageTypes.Error, APPLICATIONNAME,ex.ToString(), LoggingMessageTargets.Both); mq.Close(); mq.Dispose(); mq = null; MessageQueue.ClearConnectionCache(); Thread.Sleep(10000); } else { mq = null; } } catch (Exception ex) { RemoteLoggingManager.LogMessage(LoggingMessageTypes.Error, APPLICATIONNAME,ex.ToString(), LoggingMessageTargets.Both); mq.Close(); mq.Dispose(); mq = null; MessageQueue.ClearConnectionCache(); } } } catch(Exception ex) { RemoteLoggingManager.LogMessage(LoggingMessageTypes.Informatio