locked
The transaction aborted? RRS feed

  • Question

  • im creating a C# and WCF service which picks up msgs from MSMQ.

    This is using transactional MSMQ. within the business logic, there is a condition and that condition then places a new message on a different transactional queue however I seem to always get an exception thrown and not sure where to go from here

    "System.Transactions.TransactionAbortedException: The transaction has aborted.\r\n at System.Transactions.TransactionStatePromotedAborted.CreateAbortingClone(InternalTransaction tx)\r\n at System.Transactions.DependentTransaction..ctor(IsolationLevel isoLevel, InternalTransaction internalTransaction, Boolean blocking)\r\n at System.Transactions.Transaction.DependentClone(DependentCloneOption cloneOption)\r\n at System.Transactions.TransactionScope.SetCurrent(Transaction newCurrent)\r\n at System.Transactions.TransactionScope.PushScope()\r\n at System.Transactions.TransactionScope..ctor(TransactionScopeOption scopeOption)\r\n at TMC.Services.Implementation.InboundMessageHandler.Msmq.MsmqDispatcher.Dispatch(String queueFormatAndLocation, Object itemToPlaceOnQueue, Boolean traceMessage) in E:\\Msmq\\MsmqDispatcher.cs:line 39\r\n at TMC.Services.Implementation.InboundMessageHandler.OmhDispatcher.AckNackDispatcher.SendAckTo

    Tg(SendAckToTgRequest request) in E:\\AckNackDispatcher.cs:line 38"

    Any ideas at all?

    the code for when it is placing it on the queue:

    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 terms of the queueFormatAndLocation, it is correct:

    "FormatName:Direct=OS:.\\private$\\AckMsgs"

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

    Wednesday, September 26, 2012 11:44 AM

Answers

  • it appears that you need to use MessageQueueTransaction and MessageQueue classes to send a transactional message to another queue within the transaction you are currently in:

     using (var mqt = new MessageQueueTransaction())
                {
                    mqt.Begin();
                    MessageQueue mq = new MessageQueue(queueFormatAndLocation);
                    mq.Send(itemToPlaceOnQueue, mqt);
                    mqt.Commit();
                }


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

    • Marked as answer by ahmedilyas Wednesday, September 26, 2012 1:18 PM
    Wednesday, September 26, 2012 1:18 PM