NHibernateSagaPersister and session context

Ref.: NServiceBus.Core.dll v. 2.0.1329.2, NHibernate.dll v.

Hi everybody,
I have this configuration file for configuring NHibernateSagaPersister:

<NHibernateSagaPersisterConfig UpdateSchema="true">
      <add Key="connection.provider" Value="NHibernate.Connection.DriverConnectionProvider" />
      <add Key="connection.driver_class" Value="NHibernate.Driver.OracleDataClientDriver" />
      <add Key="connection.connection_string" Value="Data Source=XXX; User Id=YYY; Password=ZZZ" />
      <add Key="dialect" Value="NHibernate.Dialect.Oracle10gDialect" />
      <add Key="current_session_context_class" Value="NHibernate.Context.WebSessionContext" />      

I have set the “current_session_context_class” parameter to "NHibernate.Context.WebSessionContext" but the problem is that the NHibernate context of the instance object SagaPersister is always ThreadStaticSessionContext type.

Is there a reason for this or I wrong something in the parameter definition in the configuration file?

Thanks in advance.
Diego Parolin

Hi Diego

Unfortunately the version of NServiceBus you are referring to is no longer supported. I did a quick glance through the code though and it seems it was hardcoded

I can only imagine it is because for the message handling pipeline ThreadStaticSessionContext was the only context that made sense because a message was handled on a dedicated thread. Therefore session context would not overlap. To me it seems the WebSessionContext only makes sense when using a web application to send messages but not receive them.


1 Like