【问题标题】:NServiceBus in Azure Deployment TroubleAzure 中的 NServiceBus 部署问题
【发布时间】:2015-02-24 10:15:01
【问题描述】:

我在将服务部署到云端时遇到了一些问题。更准确地将 NServiceBus 与 Azure 结合使用。我已经回溯了 3 次我的步骤(创建了 3 次相同的项目),结果相同,所以我真的希望有人能指出我正确的方向。

更新 -> 2014 年 2 月 24 日
帖子中提到的降级程序集到版本 5.1.3 和部署现在可以正常工作并创建队列。可能是最新版本中的某些内容导致部署失败。

首先,我使用门户创建我的先决条件:

  • 云服务题为折扣
  • 存储帐户享有折扣
  • Service Bus 标题为 discountbus

以上 3 个都是使用快速创建创建的。

返回 Visual Studio,创建:

  • 名为 AzureTest 的新解决方案
  • 新的云服务项目名为AzureTest
  • 名为 Discount 的新 Worker Role 项目

通过 nuget 引用了以下程序集:

  • NServiceBus 5.2.0
  • NServiceBus.Azure 6.2.0
  • NServiceBus.Hosting.Azure 6.2.0
  • NServiceBus.Azure.Transports.WindowsAzureServiceBus 6.2.0

添加了一个名为 Messages 的新程序集,它将包含我要发布的命令和事件。

更改了我的云服务项目 (AzureTest) 中的设置,以便我可以获得一些日志记录:

<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString"/>

我的 EndpointConfig 如下所示:

public class EndpointConfig : IConfigureThisEndpoint, AsA_Worker
{
    public void Customize(BusConfiguration configuration)
    {
        // Nothing too complicated for now, just anything where the namespace contains commands or events
        configuration.Conventions().DefiningCommandsAs(x => x.AssemblyQualifiedName != null && x.AssemblyQualifiedName.Contains(".Commands."));
        configuration.Conventions().DefiningEventsAs(x => x.AssemblyQualifiedName != null && x.AssemblyQualifiedName.Contains(".Events."));

        configuration.UseTransport<AzureServiceBusTransport>();
        configuration.UsePersistence<AzureStoragePersistence>();

        // Docs don't state to do this however logs show this is required
        configuration.DisableFeature<TimeoutManager>();
        configuration.DisableFeature<SecondLevelRetries>();
        configuration.DisableFeature<Sagas>();
    }
}

WorkerRole 只是尝试启动和停止 NServiceBusRole:

public class WorkerRole : RoleEntryPoint
{
    private NServiceBusRoleEntrypoint nsb = new NServiceBusRoleEntrypoint();

    public override bool OnStart()
    {
        Trace.TraceInformation("Discount has been started");

        nsb.Start();

        return base.OnStart();
    }

    public override void OnStop()
    {
        Trace.TraceInformation("Discount has stopped");

        nsb.Stop();

        base.OnStop();
    }
}

ServiceConfiguration.Cloudcscfg 包含:

<ConfigurationSettings>
  <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=discount;AccountKey=[my key]" />
</ConfigurationSettings>

NSB 的配置部分:

  <MessageForwardingInCaseOfFaultConfig ErrorQueue="error" />
  <TransportConfig MaximumConcurrencyLevel="5" MaxRetries="2" MaximumMessageThroughputPerSecond="0" />
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Assembly="Messages" Type="Messages.Commands.TestCommand" Endpoint="Discount" />
    </MessageEndpointMappings>
  </UnicastBusConfig>
  <connectionStrings>
    <add name="NServiceBus/Transport" connectionString="Endpoint=sb://discountbus.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=[my key]" />
  </connectionStrings>

当我尝试通过右键单击云服务项目进行部署并发布时,我收到以下反馈:

09:34:29 - 应用诊断扩展。
09:34:50 - 准备 AzureTest 的部署 - 24/02/2015 09:34:20 与订阅 ID 'e3dbff72-f1c1-43c8-b052-3404ea5c168e' 使用服务管理 URL 'https://management.core.windows.net/'...
09:34:50 - 正在连接...
09:34:50 - 验证存储帐户 '折扣'...
09:34:50 - 上传包裹...
09:34:56 - 正在创建...
09:35:28 - 创建的部署 ID: e464ba5932fc402faf6945e8a983b52e.
09:35:28 - 角色实例 0 折扣已停止
09:35:28 - 开始...
09:35:45 - 正在初始化...
09:35:45 - 角色 Discount 的实例 0 位于 未知状态
09:36:18 - 角色 Discount 的实例 0 正在创建 虚拟机
09:37:23 - 角色折扣的实例 0 是 启动虚拟机
09:39:33 - 角色实例 0 折扣处于未知状态
09:40:06 - 角色实例 0 折扣正忙
详细信息:正在准备开始角色...系统是 初始化。 [2015-02-24T09:39:43Z]
09:42:10 - 角色实例 0 折扣正在重新启动详细信息:角色遇到错误并已 停了下来。系统初始化成功。 [2015-02-24T09:41:57Z]
09:44:14 - 角色折扣的实例 0 是 忙 详细信息:正在恢复角色...系统在

尝试将云服务项目设置为启动时在本地进行调试,但出现错误说明:

"一个未处理的异常类型 'System.Configuration.ConfigurationErrorsException' 发生在 WaWorkerHost.exe。”很遗憾,没有提供更多详细信息。

服务器资源管理器显示我的存储,但只显示指标表。

希望有人能给我指路明灯,指引我哪里出了问题。现在对这一切感到非常情绪化,并尝试做这个简单的项目近 3 天:(

干杯,DS。

【问题讨论】:

    标签: c# nservicebus azure-worker-roles azureservicebus


    【解决方案1】:

    为了更确定 azure 中发生的异常,您应该尝试使用 Intellitrace 对其进行调试(我认为现在称为历史调试)

    但我的直觉是,您没有指定要为您启用的 Azure 存储持久性使用哪个存储帐户。

    如果您仍然卡住,请不要犹豫,将您的测试项目的副本发送给我,我会看一看。

    【讨论】:

    • 我相信这个问题与我使用的 NServiceBus 版本有关。现在我不能 100% 相信这一点,但我很确定情况就是这样。我使用的是 5.1.3,但我对 5.2.0 做了一个简单的包更新,它工作正常。这可能是与配置相关的问题,但我将进一步调查。
    猜你喜欢
    • 2022-01-20
    • 1970-01-01
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    • 2012-03-23
    • 2017-06-24
    • 2019-02-22
    • 1970-01-01
    相关资源
    最近更新 更多