-
Notifications
You must be signed in to change notification settings - Fork 16
MaintenanceMode
By default, each consumer runs its own maintenance monitors (heartbeat reset, message expiration cleanup, error cleanup). The MaintenanceMode setting lets you run these monitors separately from the consumer.
Set MaintenanceMode on the consumer configuration:
queue.Configuration.MaintenanceMode = MaintenanceMode.External;| Value | Behavior |
|---|---|
Consumer (default) |
Each consumer runs its own maintenance monitors |
External |
Consumer skips maintenance monitors; they must run elsewhere |
Per-message heartbeat updates are unaffected by this setting. Consumers always update heartbeats for messages they are actively processing, regardless of mode.
Use IQueueMaintenanceService to run maintenance outside the consumer. This is registered in the queue container and can be resolved directly:
var maintenanceService = container.GetInstance<IQueueMaintenanceService>();
maintenanceService.Start();
// Check status
Console.WriteLine($"Running: {maintenanceService.IsRunning}");
Console.WriteLine($"Last run: {maintenanceService.LastRun}");
// Stop when done
maintenanceService.Stop();The Dashboard API can host maintenance on behalf of your queues. Set HostMaintenance = true on the queue options:
builder.Services.AddDotNetWorkQueueDashboard(options =>
{
options.AddConnection<SqlServerMessageQueueInit>(connectionString, conn =>
{
conn.DisplayName = "Production";
conn.AddQueue("OrderQueue", hostMaintenance: true);
});
});When enabled, the dashboard starts maintenance monitors for the queue at startup and exposes status via GET /api/v1/dashboard/queues/{queueId}/maintenance.
The corresponding consumers should set MaintenanceMode = External to avoid duplicate work.
- When running many consumer instances and you want to reduce redundant maintenance work
- When you want centralized control over maintenance scheduling
- When using the Dashboard API and want a single place to manage queue health
For any issues please use the GitHub issues