【问题标题】:NServiceBus saga not handling messages on azureNServiceBus 传奇未在 azure 上处理消息
【发布时间】:2013-08-27 15:03:41
【问题描述】:

在 azure 云服务上部署 NServiceBus sagas 时,我遇到了奇怪的行为。他们永远不会收到回复消息,永远不会醒来......尽管如果它在本地部署一切正常,那么当 sagas 在 WebApi 云服务角色上时也能正常工作......

public class EndpointConfiguration : IConfigureThisEndpoint, IWantCustomInitialization, 
    AsA_Worker, UsingTransport<AzureStorageQueue>
{
    public void Init()
    {
        Feature.Disable<Gateway>();
        Feature.Disable<SecondLevelRetries>();

        Feature.Enable<TimeoutManager>();
        Feature.Enable<Sagas>();

        Configure.With()
                .UsingContainer<AutofacContainerBuilder>()
                .AzureConfigurationSource()
                .AzureMessageQueue()
                .QueuePerInstance()
                .UseNHibernateSagaPersister()
                .UseNHibernateSubscriptionPersister()
                .UseNHibernateTimeoutPersister()
                .UnicastBus();
    }
}

这是我对 nsb 的配置

 <configSections>
    <section name="UnicastBusConfig" type="NServiceBus.Config.UnicastBusConfig, NServiceBus.Core" />
    <section name="DBSubscriptionStorageConfig" type="NServiceBus.Config.DBSubscriptionStorageConfig, NServiceBus.NHibernate" />
    <section name="NHibernateSagaPersisterConfig" type="NServiceBus.Config.NHibernateSagaPersisterConfig, NServiceBus.NHibernate" />
    <section name="TimeoutPersisterConfig" type="NServiceBus.Config.TimeoutPersisterConfig, NServiceBus.NHibernate" />
  </configSections>
  <UnicastBusConfig>
    <MessageEndpointMappings>
      <add Messages="Service.InternalMessages" Endpoint="service" />
      <add Messages="Messages" Endpoint="service" />
    </MessageEndpointMappings>
  </UnicastBusConfig>
  <DBSubscriptionStorageConfig>
    <NHibernateProperties>
      <add Key="connection.provider" Value="NHibernate.Connection.DriverConnectionProvider" />
      <add Key="connection.driver_class" Value="NHibernate.Driver.SqlClientDriver" />
      <add Key="connection.connection_string" Value="Data_Source;Connection Timeout=30;" />
      <add Key="dialect" Value="NHibernate.Dialect.MsSql2008Dialect" />
      <add Key="hbm2ddl.auto" Value="update" />
    </NHibernateProperties>
  </DBSubscriptionStorageConfig>
  <NHibernateSagaPersisterConfig>
    <NHibernateProperties>
      <add Key="connection.provider" Value="NHibernate.Connection.DriverConnectionProvider" />
      <add Key="connection.driver_class" Value="NHibernate.Driver.SqlClientDriver" />
      <add Key="connection.connection_string" Value="Data_Source;Connection Timeout=30;" />
      <add Key="dialect" Value="NHibernate.Dialect.MsSql2008Dialect" />
      <add Key="hbm2ddl.auto" Value="update" />
    </NHibernateProperties>
  </NHibernateSagaPersisterConfig>
  <TimeoutPersisterConfig>
    <NHibernateProperties>
      <add Key="connection.provider" Value="NHibernate.Connection.DriverConnectionProvider" />
      <add Key="connection.driver_class" Value="NHibernate.Driver.SqlClientDriver" />
      <add Key="connection.connection_string" Value="Data_Source;Connection Timeout=30;" />
      <add Key="dialect" Value="NHibernate.Dialect.MsSql2008Dialect" />
      <add Key="hbm2ddl.auto" Value="update" />
    </NHibernateProperties>
  </TimeoutPersisterConfig>

这就是我用于持久化者的配置

NServiceBus.Hosting.Azure、NServiceBus.NHibernate、NServiceBus.Core、NServiceBus.Azure、NServiceBus 所有 v4.0.30319

我正在使用 AzureStorageQueue,而且我确定我已经用正确的 ConfigureMapping 覆盖了 ConfigureHowToFindSaga,并且我正在回复消息,并正确指定了所有文件...

如果有任何想法,我将不胜感激,谢谢。

【问题讨论】:

    标签: azure nservicebus saga azure-storage-queues nservicebus4


    【解决方案1】:

    这将是一个有趣的问题。我看不出有什么明显的错误。

    所以症状是,它在本地工作(使用完全相同的配置?)并且在部署在 webrole 中时工作(这些是相同的传奇还是不同的传奇?)。

    关于后者的一些背景信息:webrole 与工作角色的不同之处仅在于 IIS 已正确配置,仅此而已。这也意味着在 webrole 中,您的代码在 2 个地方运行,即在 IIS 进程中和在 roleentrypoint 进程中。因此,您可能想要验证您实际上是在一个角色入口点(命名空间 NServiceBus.Azure.Hosting 而不是默认的 azure sdk 中托管。)

    如果您确定初始化是在正确的位置完成的,您可能想检查一下 azure 日志中是否有任何错误?

    如果没有提供更多详细信息,您还可以在解决方案中启用 Intellitrace 并下载跟踪以查看更详细的情况。

    作为最后一个选项,您还可以在 azure 实例(RDP'd in)上使用 windbg 进行实时调试。

    希望以上任何方法有所帮助!

    【讨论】:

    • 实际问题出在 connection_string Data_Source 值中的 MSDTC ... 并通过将 enlist=false 添加到连接字符串来修复
    猜你喜欢
    • 1970-01-01
    • 2011-09-15
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多