Particular / NServiceBus.NHibernate

Persistence support for NServiceBus using NHibernate
https://docs.particular.net/nservicebus/nhibernate/
Other
12 stars 32 forks source link

NHibernateStorageSession assumes saga connectionstring #286

Open dvdstelt opened 7 years ago

dvdstelt commented 7 years ago

Together @HEskandari , I investigated an issue related to this StackOverflow issue and came to the following conclusion:

Issue description

When you try to disable sagas and subscriptions, are left with just timeouts and provide a connectionstring for just timeouts, the persister complains about saga connectionstring not being found.

Detailed description

The NHibernatePersistence feature tries to enable timeouts, sagas, subscriptions, etc. by default. However line 21 enables NHibernateStorageSession and this is looking for a specific saga connectionstring in line 35.

When just providing the connectionstring for the timeout, after disabling everything else, it complains about a missing saga connectionstring.

        endpointConfiguration.DisableFeature<MessageDrivenSubscriptions>();
        endpointConfiguration.DisableFeature<Sagas>();
        endpointConfiguration.UsePersistence<NHibernatePersistence, StorageType.Timeouts>();

and configuration

<add name="NServiceBus/Persistence/NHibernate/Timeout" connectionString="server=.\sqlexpress;database=nservicebus; Trusted_Connection=True;" />

Workaround

Disabling the feature NHibernateStorageSession like this

        endpointConfiguration.DisableFeature<NHibernateStorageSession>();
        endpointConfiguration.DisableFeature<MessageDrivenSubscriptions>();
        endpointConfiguration.DisableFeature<Sagas>();
        endpointConfiguration.UsePersistence<NHibernatePersistence, StorageType.Timeouts>();

Suggested solution

Easiest solution is probably to make sure NHibernateStorageSession doesn't require the saga connectionstring. Maybe just have "Saga" empty in line 35. That would also require to fix the error message, since it might not have a suffix at all.

tmasternak commented 7 years ago

I don't think we should tackle it right now. We have a workaround and a single client that had issues with it.