From d55b7959321addb4b8677123c6a1f928e85a0e88 Mon Sep 17 00:00:00 2001 From: "Jeremy D. Miller" Date: Tue, 24 Mar 2026 11:55:40 -0500 Subject: [PATCH] Set minimum MaxDegreeOfParallelism to 5, add parallelism docs Change Endpoint.MaxDegreeOfParallelism default from Environment.ProcessorCount to Math.Max(Environment.ProcessorCount, 5) so low-core environments (containers, CI) get reasonable throughput. Add "Maximum Parallel Messages" documentation section to the listeners guide explaining the default and showing how to override it per endpoint or globally via opts.Policies.AllListeners. Co-Authored-By: Claude Opus 4.6 (1M context) --- docs/guide/messaging/listeners.md | 22 ++++++++++++++++++++++ src/Wolverine/Configuration/Endpoint.cs | 8 ++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/guide/messaging/listeners.md b/docs/guide/messaging/listeners.md index a3f530f18..e3696bd8e 100644 --- a/docs/guide/messaging/listeners.md +++ b/docs/guide/messaging/listeners.md @@ -133,6 +133,28 @@ ListeningAgent-->CircuitBreaker: potentially stops the listening * `ListeningAgent` is a controller within Wolverine that governs the listener lifecycle including pauses and restarts depending on load or error conditions +## Maximum Parallel Messages + +::: tip +Wolverine defaults the maximum number of parallel messages per endpoint to the greater of `Environment.ProcessorCount` +or 5. This ensures reasonable throughput even on low-core environments like containers or CI runners where `ProcessorCount` +may be as low as 1 or 2. +::: + +You can override the default parallelism per endpoint: + +```csharp +opts.ListenToRabbitQueue("high-throughput") + .BufferedInMemory() + .MaximumParallelMessages(20); +``` + +Or set a global default for all listening endpoints using a policy: + +```csharp +opts.Policies.AllListeners(x => x.MaximumParallelMessages = 5); +``` + ## Strictly Ordered Listeners In the case where you need messages from a single endpoint to be processed in strict, global order across the entire application, diff --git a/src/Wolverine/Configuration/Endpoint.cs b/src/Wolverine/Configuration/Endpoint.cs index 2eddf6042..ea34efd6e 100644 --- a/src/Wolverine/Configuration/Endpoint.cs +++ b/src/Wolverine/Configuration/Endpoint.cs @@ -184,11 +184,11 @@ protected Endpoint(Uri uri, EndpointRole role) } /// - /// Controls the maximum number of messages that could be processed at one time - /// Default is the Environment.ProcessorCount. Setting this to 1 makes this listening endpoint - /// be ordered in its processing + /// Controls the maximum number of messages that could be processed at one time. + /// Default is the greater of Environment.ProcessorCount or 5. Setting this to 1 makes this listening endpoint + /// be ordered in its processing. /// - public int MaxDegreeOfParallelism { get; set; } = Environment.ProcessorCount; + public int MaxDegreeOfParallelism { get; set; } = Math.Max(Environment.ProcessorCount, 5); /// /// If specified, directs this endpoint to use by GroupId sharding in processing.