Quantcast
Channel: Eben Roux - Software Architecture
Viewing all articles
Browse latest Browse all 10

MSMQ and TransactionScope

$
0
0

It turns out that when using TransactionScope you should be creating the MessageQueue instance inside the TransactionScope:

    using(var scope = new TransactionScope())
    using(var queue = new MessageQueue(path, true))
    {
        // timeout should be higher for remote queues
        // transaction type should be None for non-transactional queues
        var message = queue.Receive(TimeSpan.FromMilliseconds(0), MessageQueueTransactionType.Automatic);
        // ...normal processing...
        scope.Complete();
    }

So MSMQ behaves the same way that a database connection does in that one has to create the database connection inside the scope.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images