I am getting an error "Message requested was not found in the queue specified" when using transactions in remote MSMQ. If transaction is removed or if the queue is moved to same machine, everything works just fine. The queue is on Windows 2008 machine and the client (code shown below) is run on Windows 7 machine.
//Throws above error
using (MessageQueueTransaction mqTxn = new MessageQueueTransaction())
{
mqTxn.Begin();
Message message = messageQueue.ReceiveById(peekedMessage.Id, mqTxn);
mqTxn.Abort();
}
//Throws above error
using (TransactionScope txnScope = new TransactionScope())
{
Message message = messageQueue.ReceiveById(peekedMessage.Id, MessageQueueTransactionType.Automatic);
}
//Works fine
Message message = messageQueue.ReceiveById(peekedMessage.Id);
P.S. peekedMessage is messages peeked just before these calls. I have verified that the peekedMessage.Id matches with the first queue item. The queue is transactional.
MessageQueueTransaction can only be used for internal transactions so it won't work in the remote queue case.
The second way (using TransactionScope) would work as it uses DTC. DTC should be running and properly configured on both ends. By default, DTC is turned off both in Windows 2008 and Windows 7. In addition if firewall is on, DTC is to be put in the exception list. As soon as that is done, it works like a charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With