Place a TX msg on another queue within a TX? RRS feed

  • Question

  • var queue = new MessageQueue(queueFormatAndLocation);
                var msg = new System.Messaging.Message {Body = itemToPlaceOnQueue, Priority = MessagePriority.High, UseDeadLetterQueue = true, UseTracing = traceMessage};
                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                    queue.Send(msg, MessageQueueTransactionType.Automatic); // send the message
                    ts.Complete(); // complete the transaction

    In C#, if I have a message being invoked/read from an existing Transaction Queue, and I create a new message and place that on a DIFFERENT Transactional queue, I always get the exception "The Transaction aborted"

    what am I doing wrong here?

    if I simply place this message I wish to place on another queue, on its own in a seperate app - no problem. (the seperate app is not being invoked from anything. simply creating the same message type and placing it on a TX queue)

    When it gets to the using Statement and a new TransactionScope is created - from there it throws an exception in the constructor.

    Update: When I restart the main application and go through the same process again - it works fine.

    any ideas why this would happen?

    C# MVP (2007-2010) MS Vendor - MS All the way! Follower since 1995 MS Super Evangelist| MSDN Forums Moderator

    Thursday, September 20, 2012 11:47 PM