Lyo.MessageQueue
1.0.0
dotnet add package Lyo.MessageQueue --version 1.0.0
NuGet\Install-Package Lyo.MessageQueue -Version 1.0.0
<PackageReference Include="Lyo.MessageQueue" Version="1.0.0" />
<PackageVersion Include="Lyo.MessageQueue" Version="1.0.0" />
<PackageReference Include="Lyo.MessageQueue" />
paket add Lyo.MessageQueue --version 1.0.0
#r "nuget: Lyo.MessageQueue, 1.0.0"
#:package Lyo.MessageQueue@1.0.0
#addin nuget:?package=Lyo.MessageQueue&version=1.0.0
#tool nuget:?package=Lyo.MessageQueue&version=1.0.0
Lyo.MessageQueue
Portable queue + exchange abstraction (IMqService) so schedulers, workers, and gateways can compile against one contract while swapping RabbitMQ—or future brokers—behind Lyo.MessageQueue.* implementations.
Implements Lyo.Health.IHealth so dashboards can ping broker connectivity alongside DB/cache checks.
Contract highlights (IMqService)
ConnectAsync/DisconnectAsyncestablish sessions.IsConnected— synchronous snapshot for guards.
Messaging envelopes (QueueMessageEnvelope<T>)
QueueMessageEnvelope<T> carries Payload, RequeueCount, MessageId, EnqueuedAt, TraceId, and
Version alongside the payload. The internal QueueWorkerHelpers.DeserializeMessage<T> detects JSON
shaped like { Payload, RequeueCount, … } vs raw DTO JSON so you can:
- Attach
RequeueCount/ identifiers / timestamps without wrapping every caller manually. - Migrate legacy producers that still emit bare JSON objects — the first requeue from a legacy message
is automatically wrapped in an envelope by
QueueWorkerBaseso subsequent requeues count correctly.
MessageProcessingExceptionHandling (IgnoreAndRemoveFromQueue, ThrowAndRemoveFromQueue,
RequeueOnException) is the shared enum implementations expose for tuning how thrown exceptions in
message handlers are mapped to ack/nack/requeue semantics.
Hosted worker pattern (QueueWorkerBase<TRequest, TResult> where TResult : ResultBase)
- Implements
IHostedService+IDisposable+IHealth—StartAsyncconnects (if needed) and callsSubscribeToQueue;StopAsynccancels and waits up toDrainTimeoutMs(default30_000ms) for in-flight messages before returning. - Parses messages via the envelope-aware
DeserializeMessagehelper. - Executes your abstract
DoWorkAsync(TRequest, CancellationToken) → Task<TResult>. - Applies requeue heuristics: an optional
Metadata["requeue"]bool on the result overrides the default!IsSuccessrequeue. - Supports
maxRequeueCount+ optional DLQ publish (dlqName); when the count is exceeded, the original message bytes are forwarded to the DLQ if configured, otherwise the message is dropped at Error level. - Optional retry backoff via the public
RequeueDelayproperty: when set and the transport implementsIDelayedMqService, each counted requeue is republished with a broker-side delay ofRequeueDelay × attempt(linear backoff), so a failing message cannot burn through its retry budget in milliseconds. Transports without delay support republish immediately.
Hosted worker pattern (QueueWorkerBase<TRequest, TResult> where TResult : ResultBase) — Envelope retry flow
Every failure path acks the original delivery and republishes a counted copy — a bad message or a
repeatedly-throwing DoWorkAsync can never spin in an infinite broker redelivery loop:
flowchart LR
msg[Message delivered] --> des{Deserialize\nautocorrect ladder}
des -->|unrecoverable| poison[Ack + forward original bytes to DLQ]
des -->|ok| work[DoWorkAsync]
work -->|success| ack[Ack]
work -->|failure / exception| cap{RequeueCount < max?}
cap -->|yes| requeue["Ack + republish with RequeueCount+1\n(delayed by RequeueDelay × attempt when supported)"]
requeue --> msg
cap -->|no| dlq[Ack + route to DLQ or drop]
Hosted worker pattern (QueueWorkerBase<TRequest, TResult> where TResult : ResultBase) — QueueWorkerOptions
Shared defaults resolved by DI registration paths (e.g. AddJobWorker / AddJobWorkerFromConfiguration,
section name "QueueWorkerOptions") — the QueueWorkerBase constructor signature stays unchanged:
| Property | Type | Default | Purpose |
|---|---|---|---|
DefaultMaxRequeueCount |
int? |
5 |
Requeue cap applied when a worker doesn't pass an explicit maxRequeueCount. null = unlimited retries. |
RequeueDelay |
TimeSpan? |
2s |
Base retry delay (linear backoff by attempt). Requires an IDelayedMqService transport; null/zero = no delay. |
- Tracks
InFlightCount, exposes aqueue-worker:{QueueName}health probe viaCheckHealthAsync, and emits metrics via the injectedIMetrics:queue.worker.message.processing.duration(timer; tagqueue)queue.worker.messages.received/processed/requeued/deserialization.failed/dropped.max_requeue/dlqqueue.worker.started/start.failed/stoppedqueue.worker.running(gauge;1while running,0after stop)- Error records on
queue.worker.message.processing.errorandqueue.worker.message.deserialization.error
This is the production-grade path for long-running consumers in Lyo’s own job/email stacks.
Hosted worker pattern (QueueWorkerBase<TRequest, TResult> where TResult : ResultBase) — Health and diagnostics surface
MqServiceHealth—QueuesandConnectionscollections.MessageQueueInfo(Name, State?, Type?, Messages, MessagesReady, MessagesUnacknowledged, Consumers, AdditionalProperties)— generic per-queue snapshot.ConnectionInfo(User, UserProvidedName?, State, VHost)— generic connection snapshot.QueuePeekMessage(Payload, PayloadEncoding?, Exchange?, RoutingKey?, MessageCount?, Redelivered)— whatPeekQueueMessagesreturns.
Operational guidance
- Treat
byte[]as opaque at the interface—sign and compress at the app layer if payloads leave a trust zone. - Idempotency: requeue storms happen when handlers throw—make side effects idempotent or persist processing tokens.
- Health: implementors should ensure
IHealthsurfaces broker reachability; don’t lie “healthy” whenIsConnected()is false unless you intend lazy connect.
Implementations & UI
| Package | Role |
|---|---|
Lyo.MessageQueue.RabbitMq |
Production RabbitMQ.Client driver + DI helpers. |
Lyo.MessageQueue.Web.Components |
Blazor UX for queue inspection/management in internal tools. |
Lyo.MessageQueue.RabbitMq.Web.Components |
Rabbit-specific components + wiring. |
Related
Lyo.Job.Scheduler— often pairs with queues for fan-out triggers.Lyo.Health— uniform health reporting.
Dependencies
Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).
Lyo.Common— (direct, lyo)Lyo.Exceptions— (direct, lyo)Lyo.Health— (direct, lyo)Lyo.Metrics— (direct, lyo)Lyo.Result— (direct, lyo)Microsoft.Extensions.Hosting.Abstractions10.0.5— (direct, microsoft)Microsoft.Extensions.DependencyInjection.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Logging.Abstractions10.0.5— (transitive, microsoft)Microsoft.Extensions.Options.ConfigurationExtensions10.0.5— (transitive, microsoft)System.Memory4.6.3— (transitive, microsoft, netstandard2.0)System.Text.Json10.0.5— (transitive, microsoft, netstandard2.0)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Lyo.Common (>= 1.0.0)
- Lyo.Exceptions (>= 1.0.0)
- Lyo.Health (>= 1.0.0)
- Lyo.Metrics (>= 1.0.0)
- Lyo.Result (>= 1.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
-
net10.0
- Lyo.Common (>= 1.0.0)
- Lyo.Exceptions (>= 1.0.0)
- Lyo.Health (>= 1.0.0)
- Lyo.Metrics (>= 1.0.0)
- Lyo.Result (>= 1.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.5)
NuGet packages (9)
Showing the top 5 NuGet packages that depend on Lyo.MessageQueue:
| Package | Downloads |
|---|---|
|
Lyo.MessageQueue.RabbitMq
RabbitMQ implementation of the Lyo MessageQueue service for asynchronous messaging. |
|
|
Lyo.Job.Client
HTTP client for the Lyo Job API and IMqService-backed job event publisher for scheduler/worker hosts. |
|
|
Lyo.Job.Scheduler
Job scheduling and execution service dispatching jobs via RabbitMQ message queue. |
|
|
Lyo.MessageQueue.Web.Components
Reusable Blazor components for provider-neutral message queue dashboards and workbenches. |
|
|
Lyo.Job.Postgres
PostgreSQL job management data layer with EF Core, optional auto-migrations, and API endpoints for scheduling, running, and monitoring background jobs with RabbitMQ support. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 71 | 8/16/2026 |