跨域的NServiceBus和MSDTC?

时间:2016-11-18 21:37:01

标签: .net entity-framework nservicebus msdtc

所以我试图使用NServiceBus,一切顺利,直到我的应用程序试图通过EF6将数据写入数据库,我一直得到这个例外:

  

2016-11-18 13:35:28.340 INFO NServiceBus.RecoverabilityExecutor   立即重试将重试消息   ' 28392aef-de00-4162-8cca-a6c200c0e68e'因为一个例外:   System.Data.Entity.Core.EntityException:基础提供程序   打开失败。 --->   System.Transactions.TransactionManagerCommunicationException:   与底层事务管理器的通信失败。 --->   System.Runtime.InteropServices.COMException:MSDTC事务   经理无法从源事务中提取事务   经理因沟通问题。可能的原因是:防火墙   存在并且它没有MSDTC过程的例外,即   两台机器无法通过其NetBIOS名称找到对方,或者   两个中的一个未启用对网络事务的支持   交易经理。 (来自HRESULT的异常:0x8004D02B)at   System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32的   propgationTokenSize,Byte [] propgationToken,IntPtr managedIdentifier,   GUID&安培; transactionIdentifier,OletxTransactionIsolationLevel&   isolationLevel,ITransactionShim& transactionShim)at   System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(字节[]   propagationToken)---内部异常堆栈跟踪结束--- at   System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropigationToken(字节[]   propagationToken)   System.Transactions.TransactionStatePSPEOperation.PSPEPromote(InternalTransaction   tx)at   System.Transactions.TransactionStateDelegatedBase.EnterState(InternalTransaction   tx)at   System.Transactions.EnlistableStates.Promote(InternalTransaction tx)
  在System.Transactions.Transaction.Promote()at   System.Transactions.TransactionInterop.ConvertToOletxTransaction(交易   交易)   System.Transactions.TransactionInterop.GetExportCookie(交易   交易,Byte []行踪)at   System.Data.SqlClient.SqlInternalConnection.GetTransactionCookie(交易   transaction,Byte [] whereAbouts)at   System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(交易   tx)at   System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)
  在   System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(交易   交易)   System.Data.ProviderBase.DbConnectionPool.PrepareConnection(的DbConnection   owningObject,DbConnectionInternal obj,Transaction transaction)at   System.Data.ProviderBase.DbConnectionPool.TryGetConnection(的DbConnection   owningObject,UInt32 waitForMultipleObjectsTimeout,Boolean   allowCreate,Boolean onlyOneCheckConnection,DbConnectionOptions   userOptions,DbConnectionInternal&amp;连接)   System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy&LT;&GT; c__DisplayClass4&LT; b__3&GT; d__6.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.d__9 1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Core.EntityClient.EntityConnection.<OpenAsync>d__8.MoveNext() --- End of inner exception stack trace --- at System.Data.Entity.Core.EntityClient.EntityConnection.<OpenAsync>d__8.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Core.Objects.ObjectContext.<EnsureConnectionAsync>d__9.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Core.Objects.ObjectContext.<ExecuteInTransactionAsync>d__3d 1.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.d__9 1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter 1.GetResult()   在   System.Data.Entity.Core.Objects.ObjectQuery 1.<GetResultsAsync>d__e.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Utilities.TaskExtensions.CultureAwaiter 1.GetResult()   在   System.Data.Entity.Internal.LazyAsyncEnumerator 1.<FirstMoveNextAsync>d__0.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.<ForEachAsync>d__5 1.MoveNext()   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   System.Runtime.CompilerServices.TaskAwaiter 1.GetResult() at DAS.Services.Notifications.Data.Repository.AccountConfigurationRepository.<GetConfigurationAsync>d__2.MoveNext() in C:\source\DigitalAirStrike\DAS_Platform\das.services.notifications\src\DAS.Services.Notifications.Data\Repository\AccountConfigurationRepository.cs:line 38 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult()   在   DAS.Services.Notifications.Service.Sms.SmsService.d__8.MoveNext()   在   C:\源\ DigitalAirStrike \ DAS_Platform \ das.services.notifications \ SRC \ DAS.Services.Notifications.Service \ SMS \ SmsService.cs:线   92   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   System.Runtime.CompilerServices.ConfiguredTaskAwaitable 1.ConfiguredTaskAwaiter.GetResult() at DAS.Services.Notifications.Service.Sms.SmsService.<SendTextMessageAsync>d__7.MoveNext() in C:\source\DigitalAirStrike\DAS_Platform\das.services.notifications\src\DAS.Services.Notifications.Service\Sms\SmsService.cs:line 76 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at DAS.Services.Notifications.Command.MessageDelivery.SmsDeliveryStrategy.<Deliver>d__3.MoveNext() in C:\source\DigitalAirStrike\DAS_Platform\das.services.notifications\src\DAS.Services.Notifications.Command\MessageDelivery\SmsDeliveryStrategy.cs:line 19 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at DAS.Services.Notifications.Command.Handlers.SendSmsNotificationHandler.<Handle>d__3.MoveNext() in C:\source\DigitalAirStrike\DAS_Platform\das.services.notifications\src\DAS.Services.Notifications.Command\Handlers\SendSmsNotificationHandler.cs:line 32 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.LoadHandlersConnector.<Invoke>d__1.MoveNext() in C:\Build\src\NServiceBus.Core\Pipeline\Incoming\LoadHandlersConnector.cs:line 40 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.MutateIncomingMessageBehavior.<Invoke>d__0.MoveNext() in C:\Build\src\NServiceBus.Core\Pipeline\MutateInstanceMessage\MutateIncomingMessageBehavior.cs:line 28 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.DeserializeLogicalMessagesConnector.<Invoke>d__1.MoveNext() in C:\Build\src\NServiceBus.Core\Pipeline\Incoming\DeserializeLogicalMessagesConnector.cs:line 31 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.SubscriptionReceiverBehavior.<Invoke>d__1.MoveNext() in C:\Build\src\NServiceBus.Core\Routing\MessageDrivenSubscriptions\SubscriptionReceiverBehavior.cs:line 29 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.MutateIncomingTransportMessageBehavior.<Invoke>d__0.MoveNext() in C:\Build\src\NServiceBus.Core\Pipeline\MutateTransportMessage\MutateIncomingTransportMessageBehavior.cs:line 27 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.UnitOfWorkBehavior.<Invoke>d__0.MoveNext() in C:\Build\src\NServiceBus.Core\UnitOfWork\UnitOfWorkBehavior.cs:line 26 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NServiceBus.UnitOfWorkBehavior.<Invoke>d__0.MoveNext() in C:\Build\src\NServiceBus.Core\UnitOfWork\UnitOfWorkBehavior.cs:line 49 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.ProcessingStatisticsBehavior.<Invoke>d__0.MoveNext() in C:\Build\src\NServiceBus.Core\Performance\Statistics\ProcessingStatisticsBehavior.cs:line 25 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.ReceivePerformanceDiagnosticsBehavior.<Invoke>d__2.MoveNext() in C:\Build\src\NServiceBus.Core\Performance\Statistics\ReceivePerformanceDiagnosticsBehavior.cs:line 40 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.TransportReceiveToPhysicalMessageProcessingConnector.<Invoke>d__1.MoveNext() in C:\Build\src\NServiceBus.Core\Pipeline\Incoming\TransportReceiveToPhysicalMessageProcessingConnector.cs:line 37 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.MainPipelineExecutor.<Invoke>d__1.MoveNext() in C:\Build\src\NServiceBus.Core\Pipeline\MainPipelineExecutor.cs:line 32 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at NServiceBus.Transport.SQLServer.ReceiveStrategy.<TryProcessingMessage>d__12.MoveNext() in C:\Build\src\NServiceBus.SqlServer\Receiving\ReceiveStrategy.cs:line 33 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult()   在   NServiceBus.Transport.SQLServer.ReceiveWithTransactionScope.d__4.MoveNext()   在   C:\建立\ SRC \ NServiceBus.SqlServer \接收\ ReceiveWithTransactionScope.cs:行   99   ---从抛出异常的先前位置开始的堆栈跟踪结束--- at   System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务   任务)   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)   System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()   在   NServiceBus.Transport.SQLServer.ReceiveWithTransactionScope.d__1.MoveNext()   在   C:\建立\ SRC \ NServiceBus.SqlServer \接收\ ReceiveWithTransactionScope.cs:行   39

该错误暗示了以下其中一条:

  • 防火墙阻止了DTC
  • 计算机无法通过NetBIOS
  • 相互解析
  • 在一台或两台计算机上未启用对网络交易的支持

我已在运行应用程序的框和端口135上的SQL Server框中添加了入站和出站异常。

SQL Server实例正在Azure中的VM上运行。我也在网络安全组中添加了例外情况。

我已在两个方框上启用了DTC的网络连接。

当VM在DomainB上时,应用程序框在DomainA上运行

我有一段时间绕过这个。我需要做些什么才能让它发挥作用?是否有解决方法可以防止升级到DTC?

更新: 这两个域都通过某种Azure联盟运行,因此他们能够相互ping通,他们只能解决彼此的问题。主机名,所以我将IP地址添加到每个盒子的主机文件中,现在他们可以找到对方,一切似乎都在工作。

所以我现在想,我想知道是否有办法通过某种配置来解决这个问题,这样我就不必为每个应用程序框和每个开发人员添加主机条目了。想要在本地运行以进行测试的盒子。

1 个答案:

答案 0 :(得分:1)

我会尝试避免在您的方案中使用MSDTC,而是使用Outbox feature

这有帮助吗?