static async Task<List<SagaDataSnapshot>> LoadStoredCopies(DbConnectionProvider connectionProvider, string tableName) { var storedCopies = new List<SagaDataSnapshot>(); using (var connection = await connectionProvider.GetConnection()) { using (var command = connection.CreateCommand()) { command.CommandText = string.Format(@"SELECT * FROM [{0}]", tableName); using (var reader = command.ExecuteReader()) { while (await reader.ReadAsync()) { var sagaData = (ISagaData)new ObjectSerializer().Deserialize(Encoding.UTF8.GetBytes((string)reader["data"])); var metadata = JsonConvert.DeserializeObject<Dictionary<string, string>>((string)reader["metadata"]); storedCopies.Add(new SagaDataSnapshot{SagaData = sagaData, Metadata = metadata}); } } } await connection.Complete(); } return storedCopies; }
/// <summary> /// Constructs the storage using the specified connection provider and table to store its subscriptions. If the subscription /// storage is shared by all subscribers and publishers, the <paramref name="isCentralized"/> parameter can be set to true /// in order to subscribe/unsubscribe directly instead of sending subscription/unsubscription requests /// </summary> public SqlServerSubscriptionStorage(DbConnectionProvider connectionProvider, string tableName, bool isCentralized) { IsCentralized = isCentralized; _connectionProvider = connectionProvider; _tableName = tableName; }
public IDataBusStorage Create() { var consoleLoggerFactory = new ConsoleLoggerFactory(false); var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory); var sqlServerDataBusStorage = new SqlServerDataBusStorage(connectionProvider, "databus", true, consoleLoggerFactory); sqlServerDataBusStorage.Initialize(); return sqlServerDataBusStorage; }
/// <summary> /// Configures Rebus to use SQL Server as its transport. The table specified by <paramref name="tableName"/> will be used to /// store messages, and the "queue" specified by <paramref name="inputQueueName"/> will be used when querying for messages. /// The message table will automatically be created if it does not exist. /// </summary> public static void UseSqlServer(this StandardConfigurer<ITransport> configurer, string connectionStringOrConnectionStringName, string tableName, string inputQueueName) { configurer.Register(context => { var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName); var transport = new SqlServerTransport(connectionProvider, tableName, inputQueueName); transport.EnsureTableIsCreated(); return transport; }); }
public ISubscriptionStorage Create() { var consoleLoggerFactory = new ConsoleLoggerFactory(true); var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory); var storage = new SqlServerSubscriptionStorage(connectionProvider, TableName, true, consoleLoggerFactory); storage.EnsureTableIsCreated(); return storage; }
public ISagaSnapshotStorage Create() { var consoleLoggerFactory = new ConsoleLoggerFactory(true); var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory); var snapperino = new SqlServerSagaSnapshotStorage(connectionProvider, TableName, consoleLoggerFactory); snapperino.EnsureTableIsCreated(); return snapperino; }
protected override void SetUp() { var loggerFactory = new ConsoleLoggerFactory(false); var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory); var tableName = TestConfig.QueueName("data"); SqlTestHelper.DropTable(tableName); _storage = new SqlServerDataBusStorage(connectionProvider, tableName, true, loggerFactory); _storage.Initialize(); }
protected override void SetUp() { SqlTestHelper.DropTable(_tableName); var consoleLoggerFactory = new ConsoleLoggerFactory(false); var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, consoleLoggerFactory); _transport = new SqlServerTransport(connectionProvider, _tableName, QueueName, consoleLoggerFactory); _transport.EnsureTableIsCreated(); Using(_transport); _transport.Initialize(); }
protected override void SetUp() { var loggerFactory = new ConsoleLoggerFactory(false); _connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory); _dataTableName = TestConfig.QueueName("sagas"); _indexTableName = TestConfig.QueueName("sagaindex"); SqlTestHelper.DropTable(_indexTableName); SqlTestHelper.DropTable(_dataTableName); _storage = new SqlServerSagaStorage(_connectionProvider, _dataTableName, _indexTableName, loggerFactory); }
/// <summary> /// Configures the data bus to store data in a central SQL Server /// </summary> public static void StoreInSqlServer(this StandardConfigurer<IDataBusStorage> configurer, string connectionStringOrConnectionStringName, string tableName, bool automaticallyCreateTables = true) { if (configurer == null) throw new ArgumentNullException(nameof(configurer)); if (connectionStringOrConnectionStringName == null) throw new ArgumentNullException(nameof(connectionStringOrConnectionStringName)); if (tableName == null) throw new ArgumentNullException(nameof(tableName)); configurer.Register(c => { var loggerFactory = c.Get<IRebusLoggerFactory>(); var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, loggerFactory); return new SqlServerDataBusStorage(connectionProvider, tableName, automaticallyCreateTables, loggerFactory); }); }
protected override void SetUp() { var loggerFactory = new ConsoleLoggerFactory(false); var connectionProvider = new DbConnectionProvider(SqlTestHelper.ConnectionString, loggerFactory); var dataTableName = TestConfig.QueueName("sagas"); var indexTableName = TestConfig.QueueName("sagaindex"); SqlTestHelper.DropTable(indexTableName); SqlTestHelper.DropTable(dataTableName); _storage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, loggerFactory); _storage.EnsureTablesAreCreated(); }
/// <summary> /// Configures Rebus to use SQL Server to store timeouts. /// </summary> public static void StoreInSqlServer(this StandardConfigurer <ITimeoutManager> configurer, string connectionStringOrConnectionStringName, string tableName, bool automaticallyCreateTables = true) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory); var subscriptionStorage = new SqlServerTimeoutManager(connectionProvider, tableName, rebusLoggerFactory); if (automaticallyCreateTables) { subscriptionStorage.EnsureTableIsCreated(); } return(subscriptionStorage); }); }
public async Task CanDoWorkInTransaction() { var provizzle = new DbConnectionProvider(SqlTestHelper.ConnectionString); using (var dbConnection = await provizzle.GetConnection()) { using (var cmd = dbConnection.CreateCommand()) { cmd.CommandText = "insert into bimse (text) values ('hej med dig')"; await cmd.ExecuteNonQueryAsync(); } //await dbConnection.Complete(); } }
/// <summary> /// Configures Rebus to store saga snapshots in SQL Server /// </summary> public static void StoreInSqlServer(this StandardConfigurer<ISagaSnapshotStorage> configurer, string connectionStringOrConnectionStringName, string tableName, bool automaticallyCreateTables = true) { configurer.Register(c => { var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName); var snapshotStorage = new SqlServerSagaSnapshotStorage(connectionProvider, tableName); if (automaticallyCreateTables) { snapshotStorage.EnsureTableIsCreated(); } return snapshotStorage; }); }
/// <summary> /// Configures Rebus to use SQL Server to store subscriptions. Use <paramref name="isCentralized"/> = true to indicate whether it's OK to short-circuit /// subscribing and unsubscribing by manipulating the subscription directly from the subscriber or just let it default to false to preserve the /// default behavior. /// </summary> public static void StoreInSqlServer(this StandardConfigurer<ISubscriptionStorage> configurer, string connectionStringOrConnectionStringName, string tableName, bool isCentralized = false, bool automaticallyCreateTables = true) { configurer.Register(c => { var rebusLoggerFactory = c.Get<IRebusLoggerFactory>(); var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory); var subscriptionStorage = new SqlServerSubscriptionStorage(connectionProvider, tableName, isCentralized, rebusLoggerFactory); if (automaticallyCreateTables) { subscriptionStorage.EnsureTableIsCreated(); } return subscriptionStorage; }); }
/// <summary> /// Configures Rebus to use SQL Server to store sagas, using the tables specified to store data and indexed properties respectively. /// </summary> public static void StoreInSqlServer(this StandardConfigurer<ISagaStorage> configurer, string connectionStringOrConnectionStringName, string dataTableName, string indexTableName, bool automaticallyCreateTables = true) { configurer.Register(c => { var rebusLoggerFactory = c.Get<IRebusLoggerFactory>(); var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory); var sagaStorage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory); if (automaticallyCreateTables) { sagaStorage.EnsureTablesAreCreated(); } return sagaStorage; }); }
/// <summary> /// Configures Rebus to use SQL Server to store sagas, using the tables specified to store data and indexed properties respectively. /// </summary> public static void StoreInSqlServer(this StandardConfigurer <ISagaStorage> configurer, string connectionStringOrConnectionStringName, string dataTableName, string indexTableName, bool automaticallyCreateTables = true) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory); var sagaStorage = new SqlServerSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory); if (automaticallyCreateTables) { sagaStorage.EnsureTablesAreCreated(); } return(sagaStorage); }); }
static void Configure(StandardConfigurer<ITransport> configurer, string connectionString, string tableName, string inputQueueName) { configurer.Register(context => { var connectionProvider = new DbConnectionProvider(connectionString); var transport = new SqlServerTransport(connectionProvider, tableName, inputQueueName); transport.EnsureTableIsCreated(); return transport; }); configurer.OtherService<ITimeoutManager>().Register(c => new DisabledTimeoutManager()); configurer.OtherService<IPipeline>().Decorate(c => { var pipeline = c.Get<IPipeline>(); return new PipelineStepRemover(pipeline) .RemoveIncomingStep(s => s.GetType() == typeof (HandleDeferredMessagesStep)); }); }
/// <summary> /// Configures Rebus to store saga snapshots in SQL Server /// </summary> public static void StoreInSqlServer(this StandardConfigurer<ISagaSnapshotStorage> configurer, string connectionStringOrConnectionStringName, string tableName, bool automaticallyCreateTables = true) { if (configurer == null) throw new ArgumentNullException(nameof(configurer)); if (connectionStringOrConnectionStringName == null) throw new ArgumentNullException(nameof(connectionStringOrConnectionStringName)); if (tableName == null) throw new ArgumentNullException(nameof(tableName)); configurer.Register(c => { var rebusLoggerFactory = c.Get<IRebusLoggerFactory>(); var connectionProvider = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory); var snapshotStorage = new SqlServerSagaSnapshotStorage(connectionProvider, tableName, rebusLoggerFactory); if (automaticallyCreateTables) { snapshotStorage.EnsureTableIsCreated(); } return snapshotStorage; }); }
/// <summary> /// Constructs the saga storage, using the specified connection provider and tables for persistence. /// </summary> public SqlServerSagaStorage(DbConnectionProvider connectionProvider, string dataTableName, string indexTableName) { _connectionProvider = connectionProvider; _dataTableName = dataTableName; _indexTableName = indexTableName; }
/// <summary> /// Constructs the timeout manager, using the specified connection provider and table to store the messages until they're due. /// </summary> public SqlServerTimeoutManager(DbConnectionProvider connectionProvider, string tableName) { _connectionProvider = connectionProvider; _tableName = tableName; }
/// <summary> /// Constructs the timeout manager, using the specified connection provider and table to store the messages until they're due. /// </summary> public SqlServerTimeoutManager(DbConnectionProvider connectionProvider, string tableName) { _connectionProvider = connectionProvider; _tableName = tableName; }
/// <summary> /// Constructs the saga storage, using the specified connection provider and tables for persistence. /// </summary> public SqlServerSagaStorage(DbConnectionProvider connectionProvider, string dataTableName, string indexTableName) { _connectionProvider = connectionProvider; _dataTableName = dataTableName; _indexTableName = indexTableName; }
/// <summary> /// Constructs the storage using the specified connection provider and table to store its subscriptions. If the subscription /// storage is shared by all subscribers and publishers, the <paramref name="isCentralized"/> parameter can be set to true /// in order to subscribe/unsubscribe directly instead of sending subscription/unsubscription requests /// </summary> public SqlServerSubscriptionStorage(DbConnectionProvider connectionProvider, string tableName, bool isCentralized) { IsCentralized = isCentralized; _connectionProvider = connectionProvider; _tableName = tableName; }