Deleted MSMQ, transactions and ReceiveById do not work - "The requested message was not found in the specified queue"

I get the error message "The requested message was not specified in the specified queue" when using transactions in the remote MSMQ. If the transaction is deleted or if the queue is moved to the same computer, everything works fine. The queue is located on a Windows 2008 machine, and the client (code shown below) runs on a computer running Windows 7.

//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); 

PS peekedMessage are messages viewed right before these calls. I checked that peekedMessage.Id matches the first element of the queue. The queue is transactional.

+7
transactions msmq
source share
1 answer

MessageQueueTransaction can only be used for internal transactions, so it will not work in the case of a remote queue.

The second method (using TransactionScope) will work because it uses DTC. DTC must be up and running properly at both ends. By default, DTC is disabled on both Windows 2008 and Windows 7. In addition, if the firewall is turned on, DTC must be put on the exclusion list. Once this is done, it works like a charm.

+8
source share

All Articles