@@ -118,9 +118,6 @@ static ConsumerFlowStrategy creditOnChunkArrival() {
118118 *
119119 * <p>Calls to {@link MessageHandler.Context#processed()} are ignored.
120120 *
121- * <p>Consider using {@link #creditEveryNthChunk(int, int)} instead as it generates less network
122- * traffic.
123- *
124121 * @param initialCredits number of initial credits
125122 * @return flow strategy
126123 * @see com.rabbitmq.stream.ConsumerBuilder.FlowConfiguration#initialCredits(int)
@@ -175,11 +172,12 @@ static ConsumerFlowStrategy creditOnProcessedMessageCount(int initialCredits, do
175172 * Strategy that provides the specified number of initial credits and <code>n</code> credits every
176173 * <code>n</code> chunks.
177174 *
178- * <p>This strategy generates less network traffic than {@link
179- * com.rabbitmq.stream.ConsumerFlowStrategy.CreditOnChunkArrivalConsumerFlowStrategy} and should
180- * be used instead, unless <code>n</code> is equal to 1.
175+ * <p>This strategy can improve throughput for streams with small chunks (less than 30 messages
176+ * per chunk).
177+ *
178+ * <p>The number of initial credits must be at least twice as big as <code>n</code>.
181179 *
182- * <p>A rule of thumb is to set <code>n</code> to half the value of initial credits.
180+ * <p>A rule of thumb is to set <code>n</code> to a third of the value of initial credits.
183181 *
184182 * <p>Calls to {@link MessageHandler.Context#processed()} are ignored.
185183 *
@@ -195,9 +193,10 @@ static ConsumerFlowStrategy creditEveryNthChunk(int initialCredits, int n) {
195193 * Strategy that provides the specified number of initial credits and <code>n</code> credits every
196194 * <code>n</code> chunks.
197195 *
198- * <p>This strategy generates less network traffic than {@link
199- * com.rabbitmq.stream.ConsumerFlowStrategy.CreditOnChunkArrivalConsumerFlowStrategy} and should
200- * be used instead, unless <code>n</code> is equal to 1.
196+ * <p>This strategy can improve throughput for streams with small chunks (less than 30 messages
197+ * per chunk).
198+ *
199+ * <p>The number of initial credits must be at least twice as big as <code>n</code>.
201200 *
202201 * <p>Calls to {@link MessageHandler.Context#processed()} are ignored.
203202 */
@@ -213,9 +212,9 @@ private CreditEveryNthChunkConsumerFlowStrategy(int initialCredits, int n) {
213212 if (n <= 0 ) {
214213 throw new IllegalArgumentException ("The n argument must be greater than 0" );
215214 }
216- if (initialCredits <= n ) {
215+ if (n * 2 > initialCredits ) {
217216 throw new IllegalArgumentException (
218- "The number of initial credits must be greater than the limit " );
217+ "The number of initial credits must be at least twice as big as n " );
219218 }
220219 this .initialCredits = initialCredits ;
221220 this .n = n ;
0 commit comments