nhibernatepersistencenservicebusnservicebus4nservicebus-sagas

NServiceBus 4.6.5 NHibernate Saga Persister not persisting Saga Data


I am using NServiceBus with NHibernate and hosting the bus in my own process. The configuration I am using is:

Configure.ScaleOut(s => s.UseSingleBrokerQueue());
        Configure.Transactions.Enable();
        Configure.Features.Enable<Sagas>();
        Configure.Serialization.Xml();

        return
            Configure.With()
                     .DefaultBuilder()
                     .DefiningCommandsAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Commands"))
                     .DefiningEventsAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Events"))
                     .DefiningMessagesAs(type => type.Namespace != null && type.Namespace.EndsWith("Contracts.Messages"))
                     .RijndaelEncryptionService()
                     .UseTransport<RabbitMQ>()
                     .PurgeOnStartup(false)
                     .UnicastBus()
                     .RunHandlersUnderIncomingPrincipal(false)
                     .ImpersonateSender(false)
                     .LoadMessageHandlers()
                     .UseNHibernateSubscriptionPersister()
                     .UseNHibernateSagaPersister()
                     .UseNHibernateTimeoutPersister()
                     .DisableTimeoutManager()
                     .CreateBus()
                     .Start
                (() => {
                     Configure.Instance.LicensePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "NServiceBus-Licence.xml"));
                     Configure.Instance.ForInstallationOn<Windows>().Install();
                 });

with:

<connectionStrings>
    <add name="NServiceBus/Transport" connectionString="host=localhost" />
    <add name="NServiceBus/Persistence" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=testdb;Persist Security Info=True; Connect Timeout=200; Pooling=True; Max Pool Size=5000; Async=true; Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
    <add key="NServiceBus/Persistence/NHibernate/dialect" value="NHibernate.Dialect.MsSql2012Dialect" />
    <add key="NServiceBus/Persistence/NHibernate/connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
    <add key="NServiceBus/Persistence/NHibernate/connection.driver_class" value="NHibernate.Driver.Sql2008ClientDriver" />
</appSettings>

This configuration create the tables for my sagas in my SQL Server database with the fields I have specified on my saga which is great.

However, when my Saga runs and completes NServiceBus doesn't appear to have inserted records into my saga tables.

The tables are there, just no data.

Should this be expected? Does NServiceBus delete saga entries in persistence after a saga has completed successfully?


Solution

  • The answer to my own question is yes.

    NServiceBus deletes entries in saga data tables after the saga has completed.