MSMQ Async Receive

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
 
V

Vai2000

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
 
K

Klaus H. Probst

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top