/// <summary> /// Configures Rebus to store saga snapshots in SQL Server /// </summary> public static void StoreInSqlServer(this StandardConfigurer <ISagaSnapshotStorage> configurer, Func <Task <IDbConnection> > connectionFactory, string tableName, bool automaticallyCreateTables = true) { if (configurer == null) { throw new ArgumentNullException(nameof(configurer)); } if (connectionFactory == null) { throw new ArgumentNullException(nameof(connectionFactory)); } if (tableName == null) { throw new ArgumentNullException(nameof(tableName)); } configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var connectionProvider = new DbConnectionFactoryProvider(connectionFactory, rebusLoggerFactory); var snapshotStorage = new SqlServerSagaSnapshotStorage(connectionProvider, tableName, rebusLoggerFactory); if (automaticallyCreateTables) { snapshotStorage.EnsureTableIsCreated(); } return(snapshotStorage); }); }
/// <summary> /// Configures the data bus to store data in a central SQL Server /// </summary> public static void StoreInSqlServer(this StandardConfigurer<IDataBusStorage> configurer, Func<Task<IDbConnection>> connectionFactory, string tableName, bool automaticallyCreateTables = true) { if (configurer == null) throw new ArgumentNullException(nameof(configurer)); if (connectionFactory == null) throw new ArgumentNullException(nameof(connectionFactory)); if (tableName == null) throw new ArgumentNullException(nameof(tableName)); configurer.Register(c => { var loggerFactory = c.Get<IRebusLoggerFactory>(); var connectionProvider = new DbConnectionFactoryProvider(connectionFactory, loggerFactory); return new SqlServerDataBusStorage(connectionProvider, tableName, automaticallyCreateTables, loggerFactory); }); }
/// <summary> /// Configures Rebus to store saga snapshots in SQL Server /// </summary> public static void StoreInSqlServer(this StandardConfigurer<ISagaSnapshotStorage> configurer, Func<Task<IDbConnection>> connectionFactory, string tableName, bool automaticallyCreateTables = true) { if (configurer == null) throw new ArgumentNullException(nameof(configurer)); if (connectionFactory == null) throw new ArgumentNullException(nameof(connectionFactory)); if (tableName == null) throw new ArgumentNullException(nameof(tableName)); configurer.Register(c => { var rebusLoggerFactory = c.Get<IRebusLoggerFactory>(); var connectionProvider = new DbConnectionFactoryProvider(connectionFactory, rebusLoggerFactory); var snapshotStorage = new SqlServerSagaSnapshotStorage(connectionProvider, tableName, rebusLoggerFactory); if (automaticallyCreateTables) { snapshotStorage.EnsureTableIsCreated(); } return snapshotStorage; }); }