MSMQ Async Receive

  • Thread starter Thread starter Vai2000
  • Start date Start date
V

Vai2000

hi all, I have a winsvc which reads of messages out an MSMQ. Can someone
help with this problem.
If my server goes down and comes back up my WinSvc doesn't picks up messages
accumulated in the MSMQ , although my WinSvc is set to automatic restart
setting.
I have to manually go and restart the service then only it retrieves all the
messages from the MSMQ.
This is the code.....

/////////////////////////////////////////

protected override void OnStart(string[] args) // WinSvc
{
try
{
this._mqInbound.ReceiveCompleted += new
System.Messaging.ReceiveCompletedEventHandler(this.mqInbound_ReceiveComplete
d);
this._mqInbound.BeginReceive();
}
catch(Exception e)
{
// log exception
}

}

void mqInbound_ReceiveCompleted(object sender,ReceiveCompletedEventArgs
asyncResult)
{
// do something
messageQueue.BeginReceive();
}
/////////////////////////////////////////


TIA
 
Nops

Klaus H. Probst said:
Is your service marked as dependant on the MSMQ service itself?


--
Klaus H. Probst, MVP
http://www.vbbox.com/


Vai2000 said:
hi all, I have a winsvc which reads of messages out an MSMQ. Can someone
help with this problem.
If my server goes down and comes back up my WinSvc doesn't picks up messages
accumulated in the MSMQ , although my WinSvc is set to automatic restart
setting.
I have to manually go and restart the service then only it retrieves all the
messages from the MSMQ.
This is the code.....

/////////////////////////////////////////

protected override void OnStart(string[] args) // WinSvc
{
try
{
this._mqInbound.ReceiveCompleted += new
System.Messaging.ReceiveCompletedEventHandler(this.mqInbound_ReceiveComplete
d);
this._mqInbound.BeginReceive();
}
catch(Exception e)
{
// log exception
}

}

void mqInbound_ReceiveCompleted(object sender,ReceiveCompletedEventArgs
asyncResult)
{
// do something
messageQueue.BeginReceive();
}
/////////////////////////////////////////


TIA
 
Well... it should =)

Then the SCM will start your service after MSMQ and all things being equal
your code should work as you expect it to.


--
Klaus H. Probst, MVP
http://www.vbbox.com/


Vai2000 said:
Nops

Klaus H. Probst said:
Is your service marked as dependant on the MSMQ service itself?


--
Klaus H. Probst, MVP
http://www.vbbox.com/


Vai2000 said:
hi all, I have a winsvc which reads of messages out an MSMQ. Can someone
help with this problem.
If my server goes down and comes back up my WinSvc doesn't picks up messages
accumulated in the MSMQ , although my WinSvc is set to automatic restart
setting.
I have to manually go and restart the service then only it retrieves
all
the
messages from the MSMQ.
This is the code.....

/////////////////////////////////////////

protected override void OnStart(string[] args) // WinSvc
{
try
{
this._mqInbound.ReceiveCompleted += new
System.Messaging.ReceiveCompletedEventHandler(this.mqInbound_ReceiveComplete
 
Back
Top