locked
Why is this MSMQ Transaction escalated to DTC? RRS feed

  • Question

  • I have reduced a problem I'm having to the following example code:

    var inQueue = ".\private$\testqueue";
    using (var ts = new TransactionScope())
    {
        using (var q = new MessageQueue(inQueue, QueueAccessMode.Send))
        {
            for (var i = 0; i < 100000; ++i)
            {
                var msg = new Message(i);
                q.Send(msg, MessageQueueTransactionType.Automatic);
            }
        }
        ts.Complete();
    }

    As you can see, all it does it write 100,000 integers to a (transactional, local) queue using the TransactionScope pattern. My understanding is that this type of operation would not escalate to a DTC transaction.

    However, if I open up Component Services while this is running, I can see the transaction in the Local DTC > Transaction List. This means that the transaction has been escalated, right?

    Why would this be happening? I was prompted to this by bad performance in another program, and it would appear that the use of DTC for such a simple transaction may be a factor. Regardless, I just want to understand the cause.

    Any help would be appreciated.

    Monday, September 17, 2012 1:23 PM

Answers