NexJob.RabbitMQ
5.5.0
See the version list below for details.
dotnet add package NexJob.RabbitMQ --version 5.5.0
NuGet\Install-Package NexJob.RabbitMQ -Version 5.5.0
<PackageReference Include="NexJob.RabbitMQ" Version="5.5.0" />
<PackageVersion Include="NexJob.RabbitMQ" Version="5.5.0" />
<PackageReference Include="NexJob.RabbitMQ" />
paket add NexJob.RabbitMQ --version 5.5.0
#r "nuget: NexJob.RabbitMQ, 5.5.0"
#:package NexJob.RabbitMQ@5.5.0
#addin nuget:?package=NexJob.RabbitMQ&version=5.5.0
#tool nuget:?package=NexJob.RabbitMQ&version=5.5.0
NexJob.RabbitMQ
End-to-end RabbitMQ integration for NexJob, unifying RabbitMQ Triggers (Consumers) and a Resilient Outbox Producer with Publisher Confirms in a single package.
Installation
dotnet add package NexJob.RabbitMQ
1. Resilient Outbox Producer
Publishes messages to RabbitMQ exchanges and queues backed by NexJob's persistent storage, exponential retries with jitter, dead-letter dispatch, Publisher Confirms, and OpenTelemetry trace propagation.
Registration
using NexJob;
using NexJob.RabbitMQ;
builder.Services.AddNexJob()
.UsePostgreSqlStorage(...)
.AddRabbitMqProducer(options =>
{
options.HostName = builder.Configuration["RABBITMQ_HOST"]
?? Environment.GetEnvironmentVariable("RABBITMQ_HOST")
?? "localhost";
options.Port = 5672;
options.UserName = builder.Configuration["RABBITMQ_USER"] ?? "guest";
options.Password = builder.Configuration["RABBITMQ_PASS"] ?? "guest";
options.DefaultExchange = "events.exchange";
options.ConfirmTimeout = TimeSpan.FromSeconds(5);
});
Publishing Messages
Inject IScheduler into your application services or controllers:
public class OrderService(IScheduler scheduler)
{
// 1. Strongly typed object (automatically serialized to JSON)
public async Task CreateOrderAsync(OrderCreatedEvent order, CancellationToken ct)
{
await scheduler.EnqueueRabbitMqAsync(
exchange: "orders.exchange",
routingKey: "order.created",
value: order,
correlationId: order.OrderId.ToString(),
cancellationToken: ct);
}
// 2. Publish to default exchange with routing key
public async Task SendNotificationAsync(NotificationEvent notification, CancellationToken ct)
{
await scheduler.EnqueueRabbitMqAsync(
routingKey: "notifications-queue",
value: notification,
cancellationToken: ct);
}
// 3. Raw string / JSON payload
public async Task PublishRawJsonAsync(string routingKey, string rawJson, CancellationToken ct)
{
await scheduler.EnqueueRabbitMqRawAsync(
exchange: "events.exchange",
routingKey: routingKey,
value: rawJson,
cancellationToken: ct);
}
// 4. Raw binary payload
public async Task PublishBinaryAsync(string exchange, string routingKey, byte[] bytes, CancellationToken ct)
{
await scheduler.EnqueueRabbitMqRawAsync(
exchange: exchange,
routingKey: routingKey,
value: bytes,
cancellationToken: ct);
}
}
Publisher Confirms Guarantee
RabbitMqProducerClient enables Publisher Confirms (ConfirmSelect()) on every channel. A job completes with success only after RabbitMQ acknowledges that the message was received and persisted to the broker. If the broker returns a NACK or the operation times out, the producer job throws an exception, activating NexJob's retry and backoff policy.
2. RabbitMQ Trigger (Consumer)
Consumes incoming messages from RabbitMQ queues and automatically enqueues them as background jobs.
Registration
There are two ways to register which job is triggered when a message arrives:
Option A: Strongly-Typed Consumer (Recommended)
Bind a queue directly to a job handler class (IJob<string>). The job is automatically registered in DI as Transient:
builder.Services.AddNexJob()
.AddNexJobRabbitMqTrigger<ProcessOrderJob>(options =>
{
options.HostName = builder.Configuration["RABBITMQ_HOST"] ?? "localhost";
options.Port = 5672;
options.UserName = "guest";
options.Password = "guest";
options.QueueName = "incoming-orders";
options.TargetQueue = "orders";
options.PrefetchCount = 10;
});
Option B: Dynamic Message Header (nexjob.job_type)
If multiple job types share the same queue, omit the generic argument. The incoming RabbitMQ message must include the nexjob.job_type header (or have options.JobType configured as a default):
builder.Services.AddNexJob()
.AddRabbitMqTrigger(options =>
{
options.HostName = "localhost";
options.QueueName = "incoming-events";
// options.JobType = typeof(DefaultEventJob).AssemblyQualifiedName;
});
(Legacy AddNexJobRabbitMqTrigger remains supported for backward compatibility).
Inbound Message Contract
Messages consumed by the trigger expect the following headers:
nexjob.job_type: Assembly-qualified name of theIJob<string>to execute (required).traceparent: W3C distributed trace header (optional).
The message payload body is passed directly as the job input string.
3. Environment Variables (12-Factor App / Docker / K8s)
Both the Producer and Trigger support configuration via environment variables:
| Variable | Description | Default |
|---|---|---|
RABBITMQ_HOST |
Hostname or IP of the RabbitMQ server | localhost |
RABBITMQ_PORT |
Port number | 5672 |
RABBITMQ_USER |
Username for authentication | guest |
RABBITMQ_PASSWORD |
Password for authentication | guest |
RABBITMQ_VIRTUAL_HOST |
Target virtual host | / |
Or via ASP.NET Core hierarchical configuration:
{
"NexJob": {
"RabbitMq": {
"HostName": "rabbitmq.internal",
"Port": 5672,
"UserName": "admin",
"Password": "secretpassword",
"VirtualHost": "/"
}
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net8.0
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Microsoft.Extensions.Options (>= 8.0.2)
- Microsoft.Extensions.Options.DataAnnotations (>= 8.0.0)
- NexJob (>= 5.5.0)
- RabbitMQ.Client (>= 6.8.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 6.7.0 | 55 | 10/19/2026 |
| 6.6.0 | 106 | 10/18/2026 |
| 6.5.1 | 92 | 10/17/2026 |
| 6.5.0 | 84 | 10/17/2026 |
| 6.4.0 | 89 | 10/16/2026 |
| 6.3.0 | 90 | 10/12/2026 |
| 6.2.1 | 88 | 10/11/2026 |
| 6.2.0 | 83 | 10/10/2026 |
| 6.1.0 | 84 | 10/10/2026 |
| 6.0.0 | 85 | 10/9/2026 |
| 5.10.0 | 90 | 10/8/2026 |
| 5.9.0 | 87 | 10/5/2026 |
| 5.8.0 | 98 | 10/4/2026 |
| 5.7.0 | 95 | 10/1/2026 |
| 5.6.2 | 94 | 10/1/2026 |
| 5.6.1 | 91 | 9/30/2026 |
| 5.6.0 | 86 | 9/30/2026 |
| 5.5.0 | 93 | 9/25/2026 |
| 5.4.1 | 87 | 9/24/2026 |
| 5.4.0 | 92 | 9/24/2026 |