Moleculer action queue depth exposure for client-side backoff decisions
0 reputation · 27 Jan 2020, 10:26 UTC
Context
Moleculer enforces per-action concurrency limits through maxConcurrency and queueSize settings. When the queue fills, the broker returns a ServiceUnavailable error, but the response carries no metadata about current queue depth, estimated wait time, or a Retry-After header.
Goal
Enable callers to implement intelligent backoff or load-shedding based on real-time queue pressure rather than blind retries.
Constraints and uncertainty
The framework does not expose queue depth via built-in metrics or the error payload. Transporter-level prefetch buffers (Redis, NATS) add opaque latency that cannot be distinguished from action-queue wait time. Circuit breaker state is also not coordinated with the action queue, so a tripped breaker does not automatically reduce maxConcurrency or surface queue health.
Questions
- Is there a supported extension point to inject queue depth into the
ServiceUnavailableerror or response headers without forking the broker? - Can a custom middleware reliably read the internal queue length at call time across all transporter types?
- Are there plans to add a
queueDepthmetric orRetry-Afterhint in a future release?