NServiceBus saga not handling messages on azure

370 views Asked by At

I'm getting strange behavior of working NServiceBus sagas deployed on azure cloud service. They never get replied message, never wake up... although if it's deployed locally everything works fine, also sagas works correctly when it's on WebApi cloud service role...

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();
    }
}

that's my config for 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>

that's the configs that I'm using for persisters

NServiceBus.Hosting.Azure, NServiceBus.NHibernate, NServiceBus.Core, NServiceBus.Azure, NServiceBus all of v4.0.30319

I'm using AzureStorageQueue and also I'm sure that I have overridden ConfigureHowToFindSaga with proper ConfigureMapping and I'm replying message with all filed specified correctly...

I would be really appreciate for any ideas, thanks.

1

There are 1 answers

1
Yves Goeleven On

This will be an interesting one to figure out. I don't see anything obviously wrong.

So the symptoms are, it works locally (with the exact same config?) and it works when deployed in a webrole (are these the same saga's or different ones?).

Some background info on the latter: a webrole only differs from a worker role in that IIS is properly configured, that's it. This also means that in a webrole, your code is running in 2 places, in an IIS process and in the roleentrypoint process. So you may want to validate that you're actually hosting in a roleentrypoint (namespace NServiceBus.Azure.Hosting and not the default azure sdk one.)

If you're sure the initialisation is done in the right place, you may want to check if you get any errors in the azure logs?

If that doesn't give more detail, you can also enable intellitrace in your solution and download the traces to see what is going on in more detail.

And as a last option, you can also use windbg on the azure instance (RDP'd in) to debug in real time.

Hope any of the above helps!