尝试在Handler中创建Bus.SendLocal时,该操作对于事务的状态无效(本地Azure工作者)

时间:2014-01-24 13:33:18

标签: c# azure transactions handler nservicebus4

我有下一个代码:

class ProcessHandler : IHandleMessages<StartProcess>
{
    public IBus Bus { get; set; }

    public void Handle(StartProcess message)
    {
        //some long living process (over 3 min)

        Bus.SendLocal(new SameMessage()); //get error here
    }
}

错误消息:该操作对事务状态无效。

堆栈跟踪:

*在System.Transactions.TransactionState.EnlistVolatile(InternalTransaction tx,IEnlistmentNotification enlistmentNotification,EnlistmentOptions enlistmentOptions,Transaction atomicTransaction)    在System.Transactions.Transaction.EnlistVolatile(IEnlistmentNotification enlistmentNotification,EnlistmentOptions enlistmentOptions)    at NServiceBus.Azure.Transports.WindowsAzureStorageQueues.AzureMessageQueueSender.Send(TransportMessage message,Address address)在c:\ BuildAgent \ work \ ba77a0c29cee2af1 \ src \ NServiceBus.Azure.Transports.WindowsAzureStorageQueues \ AzureMessageQueueSender.cs:第51行    在NServiceBus.Unicast.UnicastBus.SendMessage(列出1 addresses, String correlationId, MessageIntentEnum messageIntent, Object[] messages) in :line 0 at NServiceBus.Unicast.UnicastBus.SendMessage(Address address, String correlationId, MessageIntentEnum messageIntent, Object[] messages) in :line 0 at NServiceBus.Unicast.UnicastBus.Send(Address address, Object[] messages) in :line 0 at NServiceBus.Unicast.UnicastBus.SendLocal(Object[] messages) in :line 0 at NServiceBus.Unicast.UnicastBus.SendLocal(Object message) in :line 0 at Amira.Merger.WorkerRole.Handlers.ProcessTPGFilesHandler.SaveToDataBase(TourML tourMLObj) in d:\AmiraProject\SourcesOfAmira-Tour\Amira\Amira.Merger.WorkerRole\Handlers\ProcessTPGFilesHandler.cs:line 161 at Amira.Merger.WorkerRole.Handlers.ProcessTPGFilesHandler.DeserializeAndSaveData() in d:\AmiraProject\SourcesOfAmira-Tour\Amira\Amira.Merger.WorkerRole\Handlers\ProcessTPGFilesHandler.cs:line 139 at Amira.Merger.WorkerRole.Handlers.ProcessTPGFilesHandler.Handle(StartProcessTPGFiles message) in d:\AmiraProject\SourcesOfAmira-Tour\Amira\Amira.Merger.WorkerRole\Handlers\ProcessTPGFilesHandler.cs:line 122 at lambda_method(Closure , Object , Object ) at NServiceBus.Unicast.HandlerInvocationCache.Invoke(Object handler, Object message, Dictionary 2字典)中:第0行    在NServiceBus.Unicast.HandlerInvocationCache.InvokeHandle(对象处理程序,对象消息)中:第0行    at NServiceBus.Pipeline.Behaviors.LoadedMessageHandlers.b_ 2(Object handlerInstance,Object message)in:line 0    在NServiceBus.Pipeline.Behaviors.InvokeHandlersBehavior.DispatchMessageToHandlersBasedOnType(IBuilder构建器,LogicalMessage toHandle,LoadedMessageHandlers loadedHandlers,BehaviorContext context)中:第0行    在NServiceBus.Pipeline.Behaviors.InvokeHandlersBehavior.Invoke(BehaviorContext context,Action next)in:line 0    在NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context)中:第0行    在NServiceBus.Pipeline.BehaviorChain。&lt;&gt; c _DisplayClass1.b_ 0()in:第0行    在NServiceBus.Sagas.SagaPersistenceBehavior.Invoke(BehaviorContext context,Action next)in:line 0    在NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context)中:第0行    在NServiceBus.Pipeline.BehaviorChain。&lt;&gt; c _DisplayClass1.b_ 0()in:第0行    在NServiceBus.Pipeline.Behaviors.LoadHandlersBehavior.Invoke(BehaviorContext context,Action next)in:line 0    在NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context)中:第0行    在NServiceBus.Pipeline.BehaviorChain。&lt;&gt; c _DisplayClass1.b_ 0()in:第0行    在NServiceBus.Pipeline.Behaviors.CallbackInvocationBehavior.Invoke(BehaviorContext context,Action next)in:line 0    在NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context)中:第0行    在NServiceBus.Pipeline.BehaviorChain。&lt;&gt; c _DisplayClass1.b_ 0()in:第0行    在NServiceBus.Pipeline.Behaviors.ApplyIncomingMessageMutatorsBehavior.Invoke(BehaviorContext context,Action next)in:line 0    在NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context)中:第0行    在NServiceBus.Pipeline.BehaviorChain。&lt;&gt; c _DisplayClass1.b_ 0()in:第0行    在NServiceBus.Pipeline.Behaviors.ExtractLogicalMessagesBehavior.Invoke(BehaviorContext context,Action next)in:line 0    在NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context)中:第0行    在NServiceBus.Pipeline.BehaviorChain。&lt;&gt; c _DisplayClass1.b_ 0()in:第0行    在NServiceBus.Pipeline.Behaviors.RaiseMessageReceivedBehavior.Invoke(BehaviorContext context,Action next)in:line 0    在NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context)中:第0行    在NServiceBus.Pipeline.BehaviorChain。&lt;&gt; c _DisplayClass1.b_ 0()in:第0行    在NServiceBus.Pipeline.Behaviors.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(BehaviorContext context,Action next)in:line 0    在NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context)中:第0行    在NServiceBus.Pipeline.BehaviorChain。&lt;&gt; c _DisplayClass1.b__0()in:第0行    在NServiceBus.UnitOfWork.UnitOfWorkBehavior.Invoke(BehaviorContext context,Action next)in:line 0 *

有人可以帮我这个吗? 感谢

1 个答案:

答案 0 :(得分:1)

Nsb处理程序被system.transactionscope包围。您可以在system.transaction-section中更改app.config中的默认超时。 Nsb fluent配置中有一个事务设置; Configure.Transactions.Advanced,也可能有超时设置。

maxtimeout是10分钟,如果你正在进行操作,你必须在machine.config中更改它(必须在启动任务上执行此操作)。

H个

//彼得