Flowly.Jobs
1.5.1
See the version list below for details.
dotnet add package Flowly.Jobs --version 1.5.1
NuGet\Install-Package Flowly.Jobs -Version 1.5.1
<PackageReference Include="Flowly.Jobs" Version="1.5.1" />
<PackageVersion Include="Flowly.Jobs" Version="1.5.1" />
<PackageReference Include="Flowly.Jobs" />
paket add Flowly.Jobs --version 1.5.1
#r "nuget: Flowly.Jobs, 1.5.1"
#:package Flowly.Jobs@1.5.1
#addin nuget:?package=Flowly.Jobs&version=1.5.1
#tool nuget:?package=Flowly.Jobs&version=1.5.1
Flowly.Jobs
Job state tracking and CRON scheduling for Flowly. Track long-running work through Created → Started → Completed / Failed with persistent state in SQL Server or PostgreSQL.
Quick Start
Also install a database backend: Flowly.Jobs.SqlServer or Flowly.Jobs.Postgres.
Define a job message
public record ProcessReportJob(Guid ReportId, DateOnly Period) : IJobMessage
{
public string Description => $"Process report {ReportId}";
public string JobTypeName => nameof(ProcessReportJob);
}
Write a job handler
[RetryPolicy(maxRetries: 2, delaySeconds: 120)]
public class ProcessReportJobHandler : JobHandler<ProcessReportJob>
{
public override async Task Handle(IJobMessageContext<ProcessReportJob> ctx)
{
await ctx.SaveState(new { Step = "Fetching data" });
var data = await FetchData(ctx.Message.ReportId, ctx.CancellationToken);
await ctx.SaveState(new { Step = "Generating PDF", Rows = data.Count });
await GeneratePdf(data, ctx.CancellationToken);
}
}
The context also exposes ctx.JobId (the id QueueJob returned, unchanged across retries) and ctx.Properties (the transport-level MessageProperties, including the CustomProperties passed to QueueJob).
Register and submit
builder.AddFlowly(configure => configure
.UseAzureServiceBus("AzureServiceBus")
.AddSqlServerJobStateTracking("Jobs")
.AddJobHandler<ProcessReportJob, ProcessReportJobHandler>()
.AddJobSubmitter<ProcessReportJob>());
public class ReportController(IJobMessageSender jobSender)
{
public Task<JobId> StartReport(DateOnly period, CancellationToken ct)
=> jobSender.QueueJob(new ProcessReportJob(Guid.NewGuid(), period), ct);
}
Tracing
With telemetry enabled, QueueJob starts a flowly.send {queueName} producer span (messaging.message.id is the JobId) and records the flowly.message.submitter.* metrics. The span of the internal message that creates the job record is its child, and so is the job handler's flowly.handle {queueName} span on the first delivery (on RabbitMQ and Azure Service Bus a retry is a child of the previous attempt's span). The span of the internal message follows the sampling decision of the job's span, so both are exported or neither is. A job message that implements IOpenTelemetryTagsProvider gets its custom tags on the send span and the handler span. When the span is started, GetOpenTelemetryTags() runs before anything is sent: when it throws, QueueJob throws that exception and no job is created. When no span is started (no listener, or the sampler drops it), the tag code does not run.
Job states
A job is Created when it is queued, Started when a handler picks it up (each retry starts it again with the next RetryAttempt), and ends Completed or Failed. The tracking service records these states from internal messages that can arrive in any order, for example when a job fails within milliseconds. Every start, completion and failure carries its attempt number, and the tracker keeps the state of the latest attempt: a late start of an attempt whose end is recorded does not reopen the job, an end of an earlier attempt is ignored, and when a redelivered attempt both fails and completes, Completed wins. Job services of older Flowly versions send no attempt with completions and failures; their updates are applied in the order they arrive. Upgrading adds a database migration, and job and tracking services can be upgraded in any order; state messages queued before the upgrade and jobs recorded before it are applied in arrival order, as before.
Start deadline
A queued job must start within 1 day, or within the time set by [JobStartTimeout("7.00:00:00")] on the job message contract (greater than zero, at most 3650 days, cannot be turned off). A job receiver that gets the job message on its first delivery after the deadline does not run the handler, marks the job Failed and completes the message; retries and broker redeliveries still run. The tracking service fails a job still Created 5 minutes after its deadline, which covers messages that expired or were never sent (QueueJob also tries to mark the job Failed when sending the job message fails), and a job message whose body cannot be read fails its job at once. A later start clears the missed-deadline and could-not-send failures. Upgrade the tracking services before the services that queue jobs, because an older tracker applies these failures to a job in any state. The job receiver warns at startup when the queue time to live of the handler is shorter than the start timeout.
Hung jobs
Flowly sends an alive signal every 30 seconds while a job handler runs. A Started job with no sign of life for 30 minutes (neither a start nor an alive signal) is marked Failed with the fault reason Hung job; Flowly does not fail a job for its run time while its alive signals arrive. The broker's limit for an unacknowledged delivery still applies when a job exceeds the RabbitMQ consumer_timeout (30 minutes by default), and how the broker ends the delivery decides what happens to the running job. That was observed to depend on the broker version and the queue type:
- RabbitMQ 3.13.7, classic queue: the broker closed the consumer's channel at the timeout. The delivery's cancellation token was cancelled and the handler kept running. The job's alive signal ends with the token, and its completion is not recorded even when the handler finishes.
- RabbitMQ 4.4.1, classic queue: the timeout was not enforced in the 164 seconds observed. The consumer stayed registered and the message stayed unacknowledged, so the job kept running as one attempt.
- RabbitMQ 4.4.1, quorum queue: between 62 and 82 seconds the broker cancelled the consumer and the message returned to ready. The channel stayed open and the token was not observed to be cancelled, so the handler keeps running, its alive signals continue and its completion can still be recorded. With more than one handler at a time, deliveries the cancellation did not return stay on the channel; when one of them exceeded the timeout in turn the broker closed the channel as on 3.13.7 and the tokens were cancelled.
- Other broker versions and queue types, and a classic queue on RabbitMQ 4.4 beyond 164 seconds, were not observed.
After a closed channel or a cancelled consumer Flowly logs an error and resumes consuming the queue on a new channel, and the message can be delivered again, so the job runs again (job handlers must be idempotent). Resuming waits for the handlers running on the channel being replaced, so this process starts the second run only after every handler running on that channel has returned. Another consumer of the queue, such as another instance, can start the second run while the first is still going. After a lost connection the RabbitMQ client's automatic recovery restores the consumer and the message is delivered again while the first run may still be going; that delivery waits until a handler of the queue is free, so this process never runs more handlers of the queue at the same time than its MaxConcurrentCalls, and with one handler at a time the second run starts only after the first has returned. After a cancelled consumer the first run can record Completed and the redelivered message still starts a second run. The job is shown as Failed (Hung job) only when no run has shown a sign of life within 30 minutes, until one starts; on Azure Service Bus the lock is renewed for at most 6 hours, after which the message can be delivered again. A job waiting for a delayed [RetryPolicy] retry is reported alive until the time the retry is scheduled for, so the delay may exceed 30 minutes. A job that was marked as hung but is still running is returned to Started (its failure time and fault reason cleared) by the next alive signal stamped later than the moment it was marked, so API consumers may briefly see Failed and then Started; an alive signal from a backlog that is older than that moment does not revive it, and neither does a job that failed or completed by report of its handler. A hung job that starts again or completes is corrected as well. None of this applies when DeleteFailedJobsAfter has already removed the record. Keep the clocks of the job and tracking services synchronized.
Recurring Jobs
[RecurringJob("Nightly Report", "0 2 * * *")]
public class NightlyReportJob : RecurringJobHandler
{
public override async Task Handle(CancellationToken ct)
=> await GenerateReport(ct);
}
builder.AddRecurringJob<NightlyReportJob>();
The scheduler polls every 5 seconds. Before it sends the trigger for a due run it records the submission time on the recurring job row with a conditional update, so exactly one trigger is sent per due run, also when several hosts with job state tracking each run a scheduler: the host whose update wins sends the trigger, the others skip it. The record is cleared when the run's start is stored. A job with a recorded submission is not triggered again for 5 minutes; if the start has not been stored by then (the trigger was lost, for example because the host stopped between recording and sending, or the service with the handler is down), the run is triggered again. Execution uses session-based queues so only one instance of each recurring job runs at a time. Make recurring jobs idempotent: a trigger that is only slow (a start update waiting for more than 5 minutes) can still lead to a second run. Upgrading adds a database migration (a nullable Triggered column on Jobs).
A database or broker that becomes unavailable while the host runs does not stop it: the scheduler and the job maintenance service log the failure and try again on their next run. Runs that became due during a database outage are submitted once at the first check after it. A failed submission is tried again after 5 minutes and a run can be executed twice around an outage, so make recurring jobs idempotent. Job state changes received while the database is unavailable are retried: the internal state handlers retry a failed message every 10 seconds, up to 60 times (about 10 minutes), and are dead-lettered only when an outage lasts longer. A state change that arrives before the job row exists is retried the same way.
Documentation
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Flowly (>= 1.5.1)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.11)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Flowly.Jobs:
| Package | Downloads |
|---|---|
|
Flowly.Jobs.SqlServer
SQL Server backend for Flowly job state tracking. |
|
|
Flowly.Jobs.Postgres
PostgreSQL backend for Flowly job state tracking. |
|
|
Flowly.Jobs.SQLite
SQLite backend for Flowly job state tracking. |
|
|
Flowly.Dashboard
Embedded web dashboard middleware for Flowly. Mounts a management UI at a configurable path prefix, providing live views of jobs, dead letters, recurring jobs, and dynamic message submission. Feature-detects Flowly.Jobs and Flowly.DeadLetters from the DI container automatically. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.6.0 | 77 | 12/1/2026 |
| 1.5.1 | 64 | 12/1/2026 |
| 1.5.0 | 332 | 11/20/2026 |
| 1.4.4 | 201 | 8/27/2026 |
| 1.4.3 | 174 | 8/13/2026 |
| 1.4.2 | 161 | 8/13/2026 |
| 1.4.1 | 174 | 8/11/2026 |
| 1.4.0 | 179 | 8/11/2026 |
| 1.3.2 | 186 | 7/3/2026 |
| 1.3.1 | 191 | 6/26/2026 |
| 1.3.0 | 221 | 6/24/2026 |
| 1.2.0 | 205 | 5/27/2026 |
| 1.1.1 | 177 | 5/22/2026 |
| 1.1.0 | 195 | 5/18/2026 |
| 1.0.1 | 162 | 5/6/2026 |
| 1.0.0 | 147 | 5/6/2026 |