Repository navigation
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 |
This setting does not affect per-message heartbeat updates. Consumers always update heartbeats for messages they are actively processing, regardless of mode.
Use IQueueMaintenanceService to run maintenance outside the consumer. The queue container registers this service, so you can resolve it 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 this option is enabled, the dashboard starts maintenance monitors for the queue at startup. It exposes the maintenance status through GET /api/v1/dashboard/queues/{queueId}/maintenance.
The corresponding consumers should set MaintenanceMode = External to avoid duplicate work.
- When you run many consumer instances and want to reduce redundant maintenance work
- When you want centralized control over maintenance scheduling
- When you use the Dashboard API and want a single place to manage queue health
For any issues please use the GitHub issues