protected override void Setup(FeatureConfigurationContext context)
        {
            var transactionTimeout = context.Settings.TransactionTimeout();
            var outboxStorage      = new OutboxStorage(context.Settings.StateManager(), transactionTimeout);

            context.Services.AddSingleton <IOutboxStorage>(outboxStorage);

            var timeToKeepDeduplicationData = context.Settings.GetOrDefault <TimeSpan?>(TimeToKeepDeduplicationEntries) ?? TimeSpan.FromHours(1);

            var frequencyToRunDeduplicationDataCleanup = context.Settings.GetOrDefault <TimeSpan?>(FrequencyToRunDeduplicationDataCleanup) ?? TimeSpan.FromSeconds(30);

            context.RegisterStartupTask(new RegisterStores(context.Settings.StateManager(), outboxStorage));
            context.RegisterStartupTask(new OutboxCleaner(outboxStorage, timeToKeepDeduplicationData, frequencyToRunDeduplicationDataCleanup));
        }
 public OutboxCleaner(OutboxStorage storage, TimeSpan timeToKeepDeduplicationData, TimeSpan frequencyToRunDeduplicationDataCleanup)
 {
     this.frequencyToRunDeduplicationDataCleanup = frequencyToRunDeduplicationDataCleanup;
     this.timeToKeepDeduplicationData            = timeToKeepDeduplicationData;
     this.storage = storage;
 }
Esempio n. 3
0
        public static async Task RegisterOutboxStorage(this IReliableStateManager stateManager, OutboxStorage storage, CancellationToken cancellationToken = default)
        {
            storage.Outbox = await stateManager.GetOrAddAsync <IReliableDictionary <string, StoredOutboxMessage> >("outbox").ConfigureAwait(false);

            storage.CleanupOld = await stateManager.GetOrAddAsync <IReliableQueue <CleanupStoredOutboxCommand> >("outboxCleanup").ConfigureAwait(false);

            storage.Cleanup = await stateManager.GetOrAddAsync <IReliableConcurrentQueue <CleanupStoredOutboxCommand> >("outboxCleanupConcurrent").ConfigureAwait(false);
        }
 public RegisterStores(IReliableStateManager stateManager, OutboxStorage storage)
 {
     outboxStorage     = storage;
     this.stateManager = stateManager;
 }
Esempio n. 5
0
        public static async Task RegisterOutboxStorage(this IReliableStateManager stateManager, OutboxStorage storage)
        {
            storage.Outbox = await stateManager.GetOrAddAsync <IReliableDictionary <string, StoredOutboxMessage> >("outbox").ConfigureAwait(false);

            storage.Cleanup = await stateManager.GetOrAddAsync <IReliableQueue <CleanupStoredOutboxCommand> >("outboxCleanup").ConfigureAwait(false);
        }