/// <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 PostgreSqlSubscriptionStorage(IPostgresConnectionProvider connectionHelper, string tableName, bool isCentralized, IRebusLoggerFactory rebusLoggerFactory) { if (rebusLoggerFactory == null) { throw new ArgumentNullException(nameof(rebusLoggerFactory)); } _connectionHelper = connectionHelper ?? throw new ArgumentNullException(nameof(connectionHelper)); _tableName = tableName ?? throw new ArgumentNullException(nameof(tableName)); IsCentralized = isCentralized; _log = rebusLoggerFactory.GetLogger <PostgreSqlSubscriptionStorage>(); }
/// <summary> /// Constructs the saga storage /// </summary> public PostgreSqlSagaStorage(IPostgresConnectionProvider connectionHelper, string dataTableName, string indexTableName, IRebusLoggerFactory rebusLoggerFactory) { if (rebusLoggerFactory == null) { throw new ArgumentNullException(nameof(rebusLoggerFactory)); } _connectionHelper = connectionHelper ?? throw new ArgumentNullException(nameof(connectionHelper)); _dataTableName = dataTableName ?? throw new ArgumentNullException(nameof(dataTableName)); _indexTableName = indexTableName ?? throw new ArgumentNullException(nameof(indexTableName)); _log = rebusLoggerFactory.GetLogger <PostgreSqlSagaStorage>(); }
/// <summary> /// Constructs the timeout manager /// </summary> public PostgreSqlTimeoutManager(IPostgresConnectionProvider 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 <PostgreSqlTimeoutManager>(); }
/// <summary> /// Constructs the storage /// </summary> public PostgreSqlSagaSnapshotStorage(IPostgresConnectionProvider connectionHelper, string tableName) { if (connectionHelper == null) { throw new ArgumentNullException(nameof(connectionHelper)); } if (tableName == null) { throw new ArgumentNullException(nameof(tableName)); } _connectionHelper = connectionHelper; _tableName = tableName; }
/// <summary> /// /// </summary> /// <param name="connectionHelper"></param> /// <param name="tableName"></param> /// <param name="inputQueueName"></param> /// <param name="rebusLoggerFactory"></param> /// <param name="asyncTaskFactory"></param> public PostgreSqlTransport(IPostgresConnectionProvider connectionHelper, string tableName, string inputQueueName, IRebusLoggerFactory rebusLoggerFactory, IAsyncTaskFactory asyncTaskFactory) { if (rebusLoggerFactory == null) { throw new ArgumentNullException(nameof(rebusLoggerFactory)); } if (asyncTaskFactory == null) { throw new ArgumentNullException(nameof(asyncTaskFactory)); } _log = rebusLoggerFactory.GetLogger <PostgreSqlTransport>(); _connectionHelper = connectionHelper ?? throw new ArgumentNullException(nameof(connectionHelper)); _tableName = tableName ?? throw new ArgumentNullException(nameof(tableName)); _inputQueueName = inputQueueName; _expiredMessagesCleanupTask = asyncTaskFactory.Create("ExpiredMessagesCleanup", PerformExpiredMessagesCleanupCycle, intervalSeconds: 60); ExpiredMessagesCleanupInterval = DefaultExpiredMessagesCleanupInterval; }
static void Configure(StandardConfigurer <ITransport> configurer, IPostgresConnectionProvider connectionProvider, string tableName, string inputQueueName) { configurer.Register(context => { var rebusLoggerFactory = context.Get <IRebusLoggerFactory>(); var asyncTaskFactory = context.Get <IAsyncTaskFactory>(); var transport = new PostgreSqlTransport(connectionProvider, tableName, inputQueueName, rebusLoggerFactory, asyncTaskFactory); 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 use PostgreSQL to store timeouts. /// </summary> public static void StoreInPostgres(this StandardConfigurer <ITimeoutManager> configurer, IPostgresConnectionProvider connectionProvider, string tableName, bool automaticallyCreateTables = true) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var rebusTime = c.Get <IRebusTime>(); var subscriptionStorage = new PostgreSqlTimeoutManager(connectionProvider, tableName, rebusLoggerFactory, rebusTime); if (automaticallyCreateTables) { subscriptionStorage.EnsureTableIsCreated(); } return(subscriptionStorage); }); }
/// <summary> /// Configures Rebus to use PostgreSQL to store sagas, using the tables specified to store data and indexed properties respectively. /// </summary> public static void StoreInPostgres(this StandardConfigurer <ISagaStorage> configurer, IPostgresConnectionProvider connectionProvider, string dataTableName, string indexTableName, bool automaticallyCreateTables = true) { configurer.Register(c => { var rebusLoggerFactory = c.Get <IRebusLoggerFactory>(); var sagaStorage = new PostgreSqlSagaStorage(connectionProvider, dataTableName, indexTableName, rebusLoggerFactory); if (automaticallyCreateTables) { sagaStorage.EnsureTablesAreCreated(); } return(sagaStorage); }); }
/// <summary> /// Configures Rebus to use PostgreSQL to store saga data snapshots, using the specified table to store the data /// </summary> public static void StoreInPostgres(this StandardConfigurer <ISagaSnapshotStorage> configurer, IPostgresConnectionProvider connectionProvider, string tableName, bool automaticallyCreateTables = true) { configurer.Register(c => { var sagaStorage = new PostgreSqlSagaSnapshotStorage(connectionProvider, tableName); if (automaticallyCreateTables) { sagaStorage.EnsureTableIsCreated(); } return(sagaStorage); }); }
/// <summary> /// Configures Rebus to use PostgreSql to transport messages as a one-way client (i.e. will not be able to receive any messages). /// The table specified by <paramref name="tableName"/> will be used to store messages. /// The message table will automatically be created if it does not exist. /// </summary> public static void UsePostgreSqlAsOneWayClient(this StandardConfigurer <ITransport> configurer, IPostgresConnectionProvider connectionProvider, string tableName) { Configure(configurer, connectionProvider, tableName, null); OneWayClientBackdoor.ConfigureOneWayClient(configurer); }
/// <summary> /// Configures Rebus to use PostgreSql 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 UsePostgreSql(this StandardConfigurer <ITransport> configurer, IPostgresConnectionProvider connectionProvider, string tableName, string inputQueueName) { Configure(configurer, connectionProvider, tableName, inputQueueName); }