使用 AzureStoragePersistence 的 NServiceBus 5 会导致在开发计算机以外的计算机上"Failed to fetch timeouts from the timeou



我尝试使用Azure表存储来持久化超时数据,但在本地开发机器以外的环境中遇到错误。

我的本地计算机正在Azure上创建超时表,并且能够成功轮询超时数据。但是,如果我在另一台服务器上本地托管相同的软件,它就无法获取超时。我收到以下错误:

    2015-02-12 09:43:50,638 [10] WARN  NServiceBus.Timeout.Hosting.Windows.TimeoutPersisterReceiver - Failed to fetch timeouts from the timeout storage
System.NullReferenceException: Object reference not set to an instance of an object.
   at NServiceBus.Timeout.Hosting.Windows.TimeoutPersisterReceiver.Poll(Object obj) in c:BuildAgentwork1b05a2fea6e4cd32srcNServiceBus.CoreTimeoutHostingWindowsTimeoutPersisterReceiver.cs:line 88
   at System.Threading.Tasks.Task.Execute()

TimeoutPersister似乎在它想要从中获取数据的时候为null

我使用NServiceBus.host托管NServiceBus。我的端点配置如下所示:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Server
    {
        public void Customize(BusConfiguration configuration)
        {
            configuration.UsePersistence<AzureStoragePersistence>();
            configuration.EndpointName("MyEndpoint");
            configuration.UseTransport<RabbitMQTransport>()
                .DisableCallbackReceiver();
            configuration.DisableFeature<Sagas>();
            configuration.ScaleOut().UseSingleBrokerQueue();();
        }
    }

我的app.config包含:

<connectionStrings>
    <add name="NServiceBus/Transport" connectionString="host=myrabbitmqserver;virtualhost=myhost;username=me;password=secret" />
  </connectionStrings>
  <AzureTimeoutPersisterConfig ConnectionString="DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=myaccouuntkey;" TimeoutManagerDataTableName="TimeoutManager" TimeoutDataTableName="TimeoutData" />

有人知道我做错了什么吗?或者有人能为我指明调查问题的正确方向吗?

更新1其他计算机上似乎没有加载NServiceBus.AAzure程序集。因此,在使用TimeoutPersister时,azure持久性功能没有初始化,导致NullReferenceException。

更新2在NServiceBus调试之后,我注意到从NServiceBus.Azure.dll程序集中提取类型时引发了异常。无法加载引用的程序集Miscrosoft.Data.Services.Client.dll 5.6.0.0。此程序集确实不在bin文件夹中。当前版本为5.6.3.0。NServiceBus.AAzure NuGet包支持版本>=5.6.0.0<6.0.0.0,但不知何故,它仍然期望版本5.6.0.0。它还在我的开发机器上工作,感觉很奇怪吗?也许我的计算机上安装了一些旧版本的Microsoft.Data.Services.Client.dll,作为Azure SDK的一部分,这些版本是在加载程序集时发现的。

更新3我的系统中确实有旧的5.6.0版本。将Microsoft.Data.xxx软件包降级到5.6.0版本暂时解决了这个问题。是否有人在使用5.6.3版本时遇到同样的问题,并找到了解决方案?

更新4自2015年2月13日起,NServiceBus.AAzure的新版本发布,现在它需要Microsoft.Data.Services.Client版本5.6.2.0。我仍然无法使用5.6.3版本。添加程序集绑定重定向也没有帮助。

绑定重定向必须添加到NServiceBus.Host.exe.config而不是app.config中。这很烦人,因为visual studio会自动更新app.config。

Yves Goeleven提供的信息:原因是CLR的默认加载行为是在进程级别,其中包括主机配置,一旦加载主机,我们就会主动切换到应用程序域级别(使用topshelf),从那时起,它将使用端点的配置。。。

但是,如果CLR需要在切换到appdomain之前解析引用,则必须将重定向放在主机级别(我想是端点级别)

它应该适用于5.6.3版本。尝试以以下方式添加程序集bindingRedirect:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
    <assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-5.6.0.0" newVersion="5.6.0.0" />
</dependentAssembly>

相关内容

最新更新