0

我有下一个代码:

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) 在 NServiceBus.Azure.Transports.WindowsAzureStorageQueues.AzureMessageQueueSender.Send( TransportMessage 消息,地址地址)在 c:\BuildAgent\work\ba77a0c29cee2af1\src\NServiceBus.Azure.Transports.WindowsAzureStorageQueues\AzureMessageQueueSender.cs:NServiceBus.Unicast.UnicastBus.SendMessage 的第 51 行(列表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, Dictionary2 字典)在:NServiceBus.Unicast.HandlerInvocationCache.InvokeHandle(对象处理程序,对象消息)的第 0 行中:NServiceBus.Pipeline.Behaviors.LoadedMessageHandlers.b_ 的第 0 行中2(对象 handlerInstance,对象消息)在:NServiceBus 的第 0 行.Pipeline.Behaviors.InvokeHandlersBehavior.DispatchMessageToHandlersBasedOnType(IBuilder builder, LogicalMessage toHandle, LoadedMessageHandlers loadedHandlers, BehaviorContext context) in :line 0 at NServiceBus.Pipeline.Behaviors.InvokeHandlersBehavior.Invoke(BehaviorContext context, Action next) in :line 0 at NServiceBus.Pipeline .BehaviorChain.InvokeNext(BehaviorContext context) in :line 0 at NServiceBus.Pipeline.BehaviorChain.<>c _DisplayClass1.b_0() in :line 0 at NServiceBus.Sagas.SagaPersistenceBehavior.Invoke(BehaviorContext context, Action next) in :line 0 at NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context) in :line 0 at NServiceBus.Pipeline.BehaviorChain。< >c _DisplayClass1.b_ 0() in :line 0 at NServiceBus.Pipeline.Behaviors.LoadHandlersBehavior.Invoke(BehaviorContext context, Action next) in :line 0 at NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context) in :line 0 at NServiceBus.Pipeline.BehaviorChain.<>c _DisplayClass1.b_0() in :line 0 at NServiceBus.Pipeline.Behaviors.CallbackInvocationBehavior.Invoke(BehaviorContext context, Action next) in :line 0 at NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context) in :line 0 at NServiceBus.Pipeline.BehaviorChain .<>c _DisplayClass1.b_ 0() in :line 0 at NServiceBus.Pipeline.Behaviors.ApplyIncomingMessageMutatorsBehavior.Invoke(BehaviorContext context, Action next) in :line 0 at NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context) in :line 0 在 NServiceBus.Pipeline.BehaviorChain.<>c _DisplayClass1.b_0() in :line 0 at NServiceBus.Pipeline.Behaviors.ExtractLogicalMessagesBehavior.Invoke(BehaviorContext context, Action next) in :line 0 at NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context) in :line 0 at NServiceBus.Pipeline.BehaviorChain .<>c _DisplayClass1.b_ 0() in :line 0 at NServiceBus.Pipeline.Behaviors.RaiseMessageReceivedBehavior.Invoke(BehaviorContext context, Action next) in :line 0 at NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context) in :line 0 在 NServiceBus.Pipeline.BehaviorChain.<>c _DisplayClass1.b_0() in :line 0 at NServiceBus.Pipeline.Behaviors.ApplyIncomingTransportMessageMutatorsBehavior.Invoke(BehaviorContext context, Action next) in :line 0 at NServiceBus.Pipeline.BehaviorChain.InvokeNext(BehaviorContext context) in :line 0 at NServiceBus.Pipeline.BehaviorChain .<>c _DisplayClass1.b__0() in :line 0 at NServiceBus.UnitOfWork.UnitOfWorkBehavior.Invoke(BehaviorContext context, Action next) in :line 0*

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

4

1 回答 1

1

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

maxtimeout 为 10 分钟,如果您的操作超过此时间,则必须在 machine.config 中更改此设置(必须在启动任务中执行此操作)。

Hth

//彼得

于 2014-01-25T09:36:14.467 回答