diff --git a/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs b/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs index 3dc91ed49..df4314a1b 100644 --- a/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs +++ b/src/modules/Elsa.Workflows.Runtime/Features/WorkflowRuntimeFeature.cs @@ -29,12 +29,9 @@ namespace Elsa.Workflows.Runtime.Features; /// Installs and configures workflow runtime features. /// [DependsOn(typeof(SystemClockFeature))] -public class WorkflowRuntimeFeature : FeatureBase +public class WorkflowRuntimeFeature(IModule module) : FeatureBase(module) { - /// - public WorkflowRuntimeFeature(IModule module) : base(module) - { - } + private bool _enableWorkflowInboxCleanupJob = true; private IDictionary WorkflowDispatcherChannels { get; set; } = new Dictionary(); @@ -126,12 +123,30 @@ public class WorkflowRuntimeFeature : FeatureBase /// A delegate to configure the . /// public Action WorkflowInboxCleanupOptions { get; set; } = _ => { }; - + /// /// A delegate to configure the . /// public Action WorkflowDispatcherOptions { get; set; } = _ => { }; + /// + /// Enables the workflow inbox cleanup job. + /// + public WorkflowRuntimeFeature EnableWorkflowInboxCleanupJob() + { + _enableWorkflowInboxCleanupJob = true; + return this; + } + + /// + /// Disables the workflow inbox cleanup job. + /// + public WorkflowRuntimeFeature DisableWorkflowInboxCleanupJob() + { + _enableWorkflowInboxCleanupJob = false; + return this; + } + /// /// Register the specified workflow type. /// @@ -188,7 +203,7 @@ public class WorkflowRuntimeFeature : FeatureBase public override void ConfigureHostedServices() { Module.ConfigureHostedService(); - Module.ConfigureHostedService(); + if (_enableWorkflowInboxCleanupJob) Module.ConfigureHostedService(); } /// @@ -240,7 +255,7 @@ public class WorkflowRuntimeFeature : FeatureBase .AddScoped() .AddScoped, ActivityExecutionRecordExtractor>() .AddScoped, WorkflowExecutionLogRecordExtractor>() - + // Stores. .AddScoped(BookmarkStore) .AddScoped(TriggerStore)