MsgQueue not aborting

B

Bill

I am using the below code to create a transaction but for some reason when
Abort() gets called the ReceiveById() is not rolled back and my message is
removed from the queue and lost. Shouldn't the message stay in the queue if
the Abort is called? Is there something else I may be missing?

MessageQueueTransaction mqt = new MessageQueueTransaction();
try
{
mqt.Begin();
Message msg =
myQueue.ReceiveById(ID,MessageQueueTransactionType.Automatic);
LogMessage logmsg = (LogMessage) msg.Body;
UpdateDatabase(logmsg)
mqt.Commit()
}catch(Exception e)
{
mqt.Abort()
}

The queue is created using this..

MessageQueue.Create(".\\" + QueueName,true);


Any help would be appreciated.
 
A

Alvin Bruney [MVP - ASP.NET]

i'm not sure the transaction to roll back the receive call, i'd use peek for
that purpose, then if the peek is successful, i'd remove the message from
the queue...

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 
B

Bill

That's what I had it doing but I though using a transaction would be more
reliable. The message queue server could go down after the peek but before
the receive.

Thanks.

Alvin Bruney said:
i'm not sure the transaction to roll back the receive call, i'd use peek
for that purpose, then if the peek is successful, i'd remove the message
from the queue...

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
 

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