I was recently implementing a Queuing solution where a client application was accessing a MSMQ Queue on a remote server.
Here are few links describing the feature in MSMQ:
- Transactional Remote Receive
- Another New Feature: Transactional Remote Receive
- How do I get transactional remote receives with MSMQ?
Outside of setting up the environment properly the main issue I faced was how do you actually code against it.
My original implementation was something like:
using (var transaction = new MessageQueueTransaction())
{
transaction.Begin();
var message = _queue.Receive(transaction);
// message processing...
transaction.Commit();
}
This would end up with a MessageQueueException and the following message: “The transaction operations sequence is invalid.”
The reason is that to get transaction remote receives to work I had to use a DTC transaction as follow:
using (var scope = new TransactionScope())
{
var message = _queue.Receive(MessageQueueTransactionType.Automatic);
// message processing...
scope.Complete();
}
From here, I could listen to a remote queue and still keep my processing transactional!
1 thought on “MSMQ Transactional Remote Receive”