/// <summary> /// Use the NHibernate backed saga persister implementation on top of Azure table storage. /// SagaData classes are automatically mapped using Fluent NHibernate conventions /// and there persistence schema is automatically generated if requested. /// </summary> /// <param name="config"></param> /// <param name="connectionString"></param> /// <param name="autoUpdateSchema"></param> /// <returns></returns> public static Configure AzureSagaPersister(this Configure config, string connectionString, bool autoUpdateSchema) { if (!Sagas.Impl.Configure.SagasWereFound) return config; //no sagas - don't need to do anything var nhibernateProperties = MsSqlConfiguration.MsSql2005 .ConnectionString(connectionString) .Provider(typeof(TableStorageConnectionProvider).AssemblyQualifiedName) .Dialect(typeof(TableStorageDialect).AssemblyQualifiedName) .Driver(typeof(TableStorageDriver).AssemblyQualifiedName) .ProxyFactoryFactory(typeof(ProxyFactoryFactory).AssemblyQualifiedName) .ToProperties(); var builder = new SessionFactoryBuilder(Configure.TypesToScan); var sessionFactory = builder.Build(nhibernateProperties, autoUpdateSchema); if (sessionFactory == null) throw new InvalidOperationException("Could not create session factory for saga persistence."); config.Configurer.RegisterSingleton<ISessionFactory>(sessionFactory); config.Configurer.ConfigureComponent<SagaPersister>(ComponentCallModelEnum.Singlecall); return config; }
/// <summary> /// Use the NHibernate backed saga persister implementation on top of Azure table storage. /// SagaData classes are automatically mapped using Fluent NHibernate conventions /// and there persistence schema is automatically generated if requested. /// </summary> /// <param name="config"></param> /// <param name="connectionString"></param> /// <param name="autoUpdateSchema"></param> /// <returns></returns> public static Configure AzureSagaPersister(this Configure config, string connectionString, bool autoUpdateSchema) { if (!Sagas.Impl.Configure.SagasWereFound) return config; //no sagas - don't need to do anything var nhibernateProperties = MsSqlConfiguration.Azure(connectionString); var builder = new SessionFactoryBuilder(Configure.TypesToScan); var sessionFactory = builder.Build(nhibernateProperties, autoUpdateSchema); if (sessionFactory == null) throw new InvalidOperationException("Could not create session factory for saga persistence."); config.Configurer.RegisterSingleton<ISessionFactory>(sessionFactory); config.Configurer.ConfigureComponent<SagaPersister>(DependencyLifecycle.InstancePerCall); return config; }