none
Remove the transaction for ServiceBus communications RRS feed

  • Question

  • We're using the ServiceBus backplane for SignalR, and when we send messages we get the following error:

    System.InvalidOperationException: Local transactions are not supported with other resource managers/DTC.
    
    Server stack trace: 
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpResourceManager.EnlistAsyncResult..ctor(SbmpResourceManager resourceManager, Transaction transaction, IRequestSessionChannel channel, SbmpMessageCreator messageCreator, Action`1 partitionInfoSetter, TimeSpan timeout, AsyncCallback callback, Object state)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpResourceManager.BeginEnlist(Transaction transaction, IRequestSessionChannel channel, SbmpMessageCreator messageCreator, Action`1 partitionInfoSetter, TimeSpan timeout, AsyncCallback callback, Object state)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<>c__DisplayClass3e.<GetAsyncSteps>b__38(TIteratorAsyncResult thisPtr, TimeSpan t, AsyncCallback c, Object s)
       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.Start()
    Ledgerscope: 
    Exception rethrown at [0]: 
       at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
       at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult result)
       at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
    Ledgerscope: 
    Exception rethrown at [1]: 
       at Microsoft.AspNet.SignalR.Messaging.ScaleoutStream.Send(Func`2 send, Object state)
       at Microsoft.AspNet.SignalR.Messaging.ScaleoutMessageBus.SendImpl(IEnumerator`1 enumerator, TaskCompletionSource`1 taskCompletionSource)
       at Microsoft.AspNet.SignalR.Messaging.ScaleoutMessageBus.Send(IList`1 messages)
       at Microsoft.AspNet.SignalR.Infrastructure.Connection.Send(ConnectionMessage message)
       at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.Outgoing(IHubOutgoingInvokerContext context)
       at Microsoft.AspNet.SignalR.Hubs.HubPipelineModule.<>c__DisplayClass1b.<BuildOutgoing>b__19(IHubOutgoingInvokerContext context)
       at Microsoft.AspNet.SignalR.Hubs.HubPipeline.Send(IHubOutgoingInvokerContext context)
       at Microsoft.AspNet.SignalR.Hubs.SignalProxy.TryInvokeMember(InvokeMemberBinder binder, Object[] args, Object& result)
       at CallSite.Target(Closure , CallSite , Object , JobLog[] )
       at Ledgerscope.DomainModel.Messaging.ClientStreamJobLogger.SendMessage(Guid id, String msg, SourceComponent source, Severity severity) in c:\Users\Matthew\Source\Repos\Core\LedgerscopeWeb\Ledgerscope.DomainModel\Messaging\JobLoggers\ClientStreamJobLogger.cs:line 27
       at Ledgerscope.DomainModel.Messaging.AggregateJobLogger.<>c__DisplayClass2.<SendMessage>b__0(IJobLogger a) in c:\Users\Matthew\Source\Repos\Core\LedgerscopeWeb\Ledgerscope.DomainModel\Messaging\JobLoggers\AggregateJobLogger.cs:line 28
       at System.Threading.Tasks.Parallel.<>c__DisplayClassf`1.<ForWorker>b__c()
       at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
       at System.Threading.Tasks.Task.<>c__DisplayClass11.<ExecuteSelfReplicating>b__10(Object param0)
       --- End of inner exception stack trace ---
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
       at System.Threading.Tasks.Task.Wait()
       at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
       at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
       at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
       at Ledgerscope.DomainModel.Messaging.AggregateJobLogger.SendMessage(Guid id, String msg, SourceComponent source, Severity severity) in c:\Users\Matthew\Source\Repos\Core\LedgerscopeWeb\Ledgerscope.DomainModel\Messaging\JobLoggers\AggregateJobLogger.cs:line 28
    ---> (Inner Exception #0) System.InvalidOperationException: Local transactions are not supported with other resource managers/DTC.
    

    Is there an easy way to disable transactional behaviour for ServiceBus? We don't need it to be in a transaction at all.

    Wednesday, July 2, 2014 4:38 PM

All replies

  • Hi,

    Service Bus does not support DTC. we could get this information from this thread: http://social.msdn.microsoft.com/Forums/windowsazure/en-US/817c325e-b439-49ac-aec8-98c0c7c83cc0/local-transactions-are-not-supported-with-other-resource-managersdtc?forum=servbus

    >>Is there an easy way to disable transactional behaviour for ServiceBus?

    As far as I know, If you consider using Service Bus, your solution requires transactional behavior and atomicity when sending or receiving multiple messages from a queue. refer to http://msdn.microsoft.com/en-us/library/hh767287.aspx for more details.

    Best Regards,

    Jambor


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, July 3, 2014 9:29 AM
    Moderator
  • Hi Jambor,

    So are you saying that I need to make sure that the call to ServiceBus happens on a separate thread than the one my transaction is in?

    I don't want the ServiceBus call to be part of the transaction at all, but finding resources on how to disable it is proving tricky.

    Regards,
    Matthew

    Thursday, July 3, 2014 10:08 AM
  • This error message does not mean Service Bus is using transaction. It points out you're using Service Bus in a transaction environment. So there's no place in Service Bus for you to "turn off" transaction. Can you check if you have other code that might be using transaction? You may be interest in http://blogs.msdn.com/b/clemensv/archive/2012/07/30/transactions-in-windows-azure-with-service-bus-an-email-discussion.aspx as well.
    Monday, July 7, 2014 7:09 AM
  • Thanks for the reply. I know that I'm using Service Bus with an ambient transaction and that's something I can't change. I don't need Service Bus to be part of the transaction (eg I don't need transactional behaviour for Service Bus). I suppose my question is how do I make sure that Service Bus does not try and join the transaction and therefore not error?
    Monday, July 7, 2014 8:18 AM
  • Haven't managed to get to the bottom of this yet. To recap, my issue is that ServiceBus is being used to carry log messages. These logs are generated throughout the application (using log4net) and if they are generated when there is an ambient transaction (such as when an EF context exists) then the calls to ServiceBus are failing with the error.

    Wednesday, September 10, 2014 11:55 PM