Hi,
THe eventargs contains the message. I have the following event handler for
PeekCompleted:
private void ReceiveQ_PeekCompleted(object sender, PeekCompletedEventArgs e)
{
if (e.Message.CorrelationId != _correlationId)
{
messageQueue.BeginPeek(_timeOut);
return;
}
MessageQueue messageQueue = sender as MessageQueue;
Message message = messageQueue.EndPeek(e.AsyncResult);
}
My question is what if there is an error on the other side and the message
never gets placed onto the queue?? How can I timeout gracefully if BeginPeek
is being called each time?
Thanks
Paul
[EMAIL PROTECTED]
> Date: Sat, 5 Aug 2006 14:16:28 -0500> From: [EMAIL PROTECTED]> Subject: Re:
> [ADVANCED-DOTNET] ReceiveByCorrelationId + MSMQ> To:
> [email protected]> > I think you can just do a BeginPeek
> and check the correlationId against the> message you receive from the
> EndPeek. If it is [one of your outstanding]> message[s], then
> receiveByCorrelationId. If not, then ignore and BeginPeek> again. Sorry, I
> haven't worked with MSMQ in over a year, so the details are> a bit rusty, but
> I think that should work for you.> > On 8/5/06, Paul Cowan <[EMAIL
> PROTECTED]> wrote:> >> > Hi,> >> > We are creating a web application that
> unfortunately has to communicate> > with a product called Navision. The
> communication is to send and receive> > xml documents via MSMQ.> > The
> process is we send a message to one queue and receive messages on> > another
> queue. The only reliable way I have been able to marry these> > messages
> together is to by setting the CorrelationId of the response message> > to be
> the id of the request message.So far I am doing this synchronously> > using
> the ReceiveByCorrelationId method. I have grave worries of how this> > will
> scale and I don't think it is thread safe.> >> > My code is as follows:> >> >
> while (receiveQ.PeekByCorrelationId(messageId, _timeOut) != null)> > {> >
> message = receiveQ.ReceiveByCorrelationId(messageId, _timeOut);> > }> >> > I
> would like to do this asynchronously but am really not sure how to go> >
> about this.> >> > Can anyone with MSMQ experience tell me how I can
> accomplish this problem> > asynchronously??> > Thanks> > Paul> >> >> >
> ===================================> > This list is hosted by
> DevelopMentor(r) http://www.develop.com> >> > View archives and manage your
> subscription(s) at> > http://discuss.develop.com> >> >
> ===================================> This list is hosted by DevelopMentorĀ®
> http://www.develop.com> > View archives and manage your subscription(s) at
> http://discuss.develop.com
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com