/// <summary> /// Constructs the subscription storage, storing subscriptions in the specified <paramref name="tableName"/>. /// If <paramref name="isCentralized"/> is true, subscribing/unsubscribing will be short-circuited by manipulating /// subscriptions directly, instead of requesting via messages /// </summary> public MySqlSubscriptionStorage(MySqlConnectionHelper connectionHelper, string tableName, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory) { _connectionHelper = connectionHelper; _tableName = tableName; IsCentralized = isCentralized; _log = rebusLoggerFactory.GetLogger <MySqlSubscriptionStorage>(); }
public TestIdempotentMessageStorage() { MySqlTestHelper.DropTableIfExists(_tableName).Wait(); var consoleLoggerFactory = new ConsoleLoggerFactory(false); var connectionHelper = new MySqlConnectionHelper(MySqlTestHelper.ConnectionString); _messageStorage = new MySqlMessageStorage(connectionHelper, _tableName, consoleLoggerFactory); _messageStorage.EnsureTablesAreCreated().Wait(); Using(_messageStorage); }
/// <summary> /// Constructs the timeout manager /// </summary> public MySqlTimeoutManager(MySqlConnectionHelper connectionHelper, string tableName, IRebusLoggerFactory rebusLoggerFactory, IRebusTime rebusTime) { if (rebusLoggerFactory == null) { throw new ArgumentNullException(nameof(rebusLoggerFactory)); } _connectionHelper = connectionHelper ?? throw new ArgumentNullException(nameof(connectionHelper)); _tableName = tableName ?? throw new ArgumentNullException(nameof(tableName)); _rebusTime = rebusTime ?? throw new ArgumentNullException(nameof(rebusTime)); _log = rebusLoggerFactory.GetLogger <MySqlTimeoutManager>(); }
/// <summary> /// Constructs a MySql transport. /// </summary> /// <param name="connectionHelper"></param> /// <param name="tableName">The name of the table used as the transport.</param> /// <param name="inputQueueName">The name of the queue on which messages are received.</param> /// <param name="rebusLoggerFactory"></param> /// <param name="asyncTaskFactory"></param> public MySqlTransport(MySqlConnectionHelper connectionHelper, string tableName, string inputQueueName, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory) { _connectionHelper = connectionHelper; _tableName = tableName; _inputQueueName = inputQueueName; _asyncTaskFactory = asyncTaskFactory; ExpiredMessagesCleanupInterval = DefaultExpiredMessagesCleanupInterval; _expiredMessagesCleanupTask = asyncTaskFactory.Create("ExpiredMessagesCleanup", PerformExpiredMessagesCleanupCycle, intervalSeconds: 60); _log = rebusLoggerFactory.GetLogger <MySqlTransport>(); }
/// <summary> /// Constructs the storage /// </summary> public MySqlSagaSnapshotStorage(MySqlConnectionHelper connectionHelper, string tableName) { if (connectionHelper == null) { throw new ArgumentNullException(nameof(connectionHelper)); } if (tableName == null) { throw new ArgumentNullException(nameof(tableName)); } _connectionHelper = connectionHelper; _tableName = tableName; }
protected override void SetUp() { MySqlTestHelper.DropTableIfExists(_tableName); var consoleLoggerFactory = new ConsoleLoggerFactory(false); var asyncTaskFactory = new TplAsyncTaskFactory(consoleLoggerFactory); var connectionHelper = new MySqlConnectionHelper(MySqlTestHelper.ConnectionString); _transport = new MySqlTransport(connectionHelper, _tableName, QueueName, consoleLoggerFactory, asyncTaskFactory); _transport.EnsureTableIsCreated(); Using(_transport); _transport.Initialize(); _cancellationToken = new CancellationTokenSource().Token; }
/// <summary> /// Constructs a MySql transport. /// </summary> public MySqlTransport(MySqlConnectionHelper connectionHelper, string tableName, string inputQueueName, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory, IRebusTime rebusTime) { if (rebusLoggerFactory == null) { throw new ArgumentNullException(nameof(rebusLoggerFactory)); } _connectionHelper = connectionHelper; _tableName = tableName; _inputQueueName = inputQueueName; _asyncTaskFactory = asyncTaskFactory ?? throw new ArgumentNullException(nameof(asyncTaskFactory)); _rebusTime = rebusTime ?? throw new ArgumentNullException(nameof(rebusTime)); ExpiredMessagesCleanupInterval = DefaultExpiredMessagesCleanupInterval; _expiredMessagesCleanupTask = asyncTaskFactory.Create("ExpiredMessagesCleanup", PerformExpiredMessagesCleanupCycle, intervalSeconds: 60); _log = rebusLoggerFactory.GetLogger <MySqlTransport>(); }
public ITransport Create(string inputQueueAddress) { var tableName = ("rebus_messages_" + TestConfig.Suffix).TrimEnd('_'); _tablesToDrop.Add(tableName); var consoleLoggerFactory = new ConsoleLoggerFactory(false); var connectionHelper = new MySqlConnectionHelper(MySqlTestHelper.ConnectionString); var asyncTaskFactory = new TplAsyncTaskFactory(consoleLoggerFactory); var transport = new MySqlTransport(connectionHelper, tableName, inputQueueAddress, consoleLoggerFactory, asyncTaskFactory); _disposables.Add(transport); transport.EnsureTableIsCreated(); transport.Initialize(); return(transport); }
/// <summary> /// Constructs the saga storage /// </summary> public MySqlSagaStorage(MySqlConnectionHelper connectionHelper, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory) { if (connectionHelper == null) { throw new ArgumentNullException(nameof(connectionHelper)); } if (dataTableName == null) { throw new ArgumentNullException(nameof(dataTableName)); } if (indexTableName == null) { throw new ArgumentNullException(nameof(indexTableName)); } if (rebusLoggerFactory == null) { throw new ArgumentNullException(nameof(rebusLoggerFactory)); } _connectionHelper = connectionHelper; _dataTableName = dataTableName; _indexTableName = indexTableName; _log = rebusLoggerFactory.GetLogger <MySqlSagaStorage>(); }
/// <summary> /// Configures Rebus to use MySQL 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 StoreInMySql(this StandardConfigurer <ISubscriptionStorage> configurer, string connectionString, string tableName, bool isCentralized = false, bool automaticallyCreateTables = true) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var connectionHelper = new MySqlConnectionHelper(connectionString); var subscriptionStorage = new MySqlSubscriptionStorage( connectionHelper, tableName, isCentralized, rebusLoggerFactory); if (automaticallyCreateTables) { var createTableTask = subscriptionStorage.EnsureTableIsCreated(); createTableTask.Wait(); // wait at least 1min to make sure the tables are correctly created. if (createTableTask.Exception != null) { throw createTableTask.Exception; } } return(subscriptionStorage); }); }