MsgQueue not aborting

  • Thread starter Thread starter Bill
  • Start date Start date
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.
 
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
 
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
 
Back
Top