Naravel.Queue
0.2.0
dotnet add package Naravel.Queue --version 0.2.0
NuGet\Install-Package Naravel.Queue -Version 0.2.0
<PackageReference Include="Naravel.Queue" Version="0.2.0" />
<PackageVersion Include="Naravel.Queue" Version="0.2.0" />
<PackageReference Include="Naravel.Queue" />
paket add Naravel.Queue --version 0.2.0
#r "nuget: Naravel.Queue, 0.2.0"
#:package Naravel.Queue@0.2.0
#addin nuget:?package=Naravel.Queue&version=0.2.0
#tool nuget:?package=Naravel.Queue&version=0.2.0
Naravel.Queue
A Laravel-inspired, driver-based background job queue for .NET: dispatch, retry with backoff, chaining, batching and a background worker.
| Fact | Detail |
|---|---|
| Install | dotnet add package Naravel.Queue |
| Targets | .NET 10 |
| Needs | Naravel.Foundation, which NuGet installs with it |
| Drivers | install one next to this package: Memory (in-process), File, Redis, Database, RabbitMQ or Kafka (listed below) |
What you get
- Dispatch with options. Per job you choose the connection, the queue, a delay, a priority from 0 to 9 and the maximum number of attempts.
- Retry with backoff, chaining and batching. A job lists its own backoff delays;
Chainruns jobs one after another, andBatchAsyncgroups jobs and counts how many succeeded and failed. - A background worker.
AddQueueWorkerruns the jobs; failed jobs land in a failed-job store thatFailedJobManagerlets you inspect. - The driver is a configuration value. Memory, file, Redis, database (any EF Core provider), RabbitMQ or Kafka: the store's
Driverpicks the backend. Kafka is the one driver without delayed delivery. - At-least-once delivery, stated plainly. A job can run more than once after a crash, so write jobs that can safely run twice.
Quick start
{
"NaravelQueue": {
"Default": "local",
"Stores": { "local": { "Driver": "memory" } }
}
}
using Naravel.Queue.Dispatch;
using Naravel.Queue.Extensions;
using Naravel.Queue.Jobs;
builder.Services.AddQueue(builder.Configuration); // reads the "NaravelQueue" section; the driver package adds its own AddXxxDriver call after it
builder.Services.AddQueueWorker(); // the hosted service that runs the jobs; a process that only dispatches leaves it out
public sealed class SendWelcomeEmail : Job
{
public string ToEmail { get; set; } = "";
public SendWelcomeEmail() { } // the worker rebuilds the job from JSON, so it needs this constructor
public SendWelcomeEmail(string toEmail) => ToEmail = toEmail;
public override Task HandleAsync(JobContext context, CancellationToken cancellationToken) =>
Task.CompletedTask; // your work goes here
}
// jobs is an injected IJobDispatcher
var id = await jobs.DispatchAsync(new SendWelcomeEmail("ada@example.com"), cancellationToken: ct);
The store above uses the memory driver, so it needs Naravel.Queue.Memory and its AddMemoryDriver(builder.Configuration) call; every other driver is chosen the same way, by the Driver of the store. DispatchAsync returns the message id, or null when the job is an IUniqueJob and an identical job is already waiting or running; unique jobs need AddQueueCoordination() from Naravel.Queue.Coordination and are covered in the coordination guide. The worker takes jobs from the default queue, one at a time, unless AddQueueWorker is given other Queues or a Concurrency.
Related packages
| Package | Adds |
|---|---|
Naravel.Queue.Memory |
In-process driver with no dependencies, for tests and local development |
Naravel.Queue.File |
JSON files on disk: durable, no external service |
Naravel.Queue.Redis |
Redis driver on StackExchange.Redis: priority buckets, delayed jobs, recovery of jobs a crashed worker left behind |
Naravel.Queue.Database |
Any EF Core provider: SQL Server, PostgreSQL, SQLite, MySQL |
Naravel.Queue.RabbitMQ |
RabbitMQ driver; delayed jobs by per-message TTL and dead-lettering, no plugin required |
Naravel.Queue.Kafka |
Kafka driver on Confluent.Kafka; it does not support delayed delivery |
Naravel.Queue.Coordination |
Optional job middleware over Naravel.Cache locks: WithoutOverlapping, RateLimited, ThrottlesExceptions |
Naravel.Queue.Encryption |
Optional: encrypts the payload of jobs marked IShouldBeEncrypted with ASP.NET Core Data Protection |
Learn more
- Queue: English guide
- Changelog · Source and issues · MIT license
Part of Naravel: Laravel's names, .NET's type system. All Naravel packages share one version.
| 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
- Microsoft.Extensions.Configuration (>= 10.0.14)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.14)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.14)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.14)
- Naravel.Foundation (>= 0.2.0)
NuGet packages (11)
Showing the top 5 NuGet packages that depend on Naravel.Queue:
| Package | Downloads |
|---|---|
|
Naravel.Queue.File
File-based queue driver for Naravel.Queue - durable, zero external services required, JSON files on disk. |
|
|
Naravel.Queue.Redis
Redis queue driver for Naravel.Queue, built on StackExchange.Redis - priority buckets, delayed jobs and automatic reclaim of jobs left behind by a crashed worker. |
|
|
Naravel.Queue.Kafka
Kafka queue driver for Naravel.Queue, built on Confluent.Kafka - semantics adapted for a log-based broker (see class docs for details). |
|
|
Naravel.Queue.Memory
In-process "memory" queue driver for Naravel.Queue - zero dependencies, ideal for tests and local development. |
|
|
Naravel.Queue.RabbitMQ
RabbitMQ queue driver for Naravel.Queue - delayed jobs via per-message TTL + dead-lettering, no plugin required. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Release notes: https://github.com/km-arc/Naravel/releases/tag/v0.2.0 - full history: https://github.com/km-arc/Naravel/blob/main/CHANGELOG.md