@@ -118,9 +118,6 @@ static ConsumerFlowStrategy creditOnChunkArrival() {
118
118
*
119
119
* <p>Calls to {@link MessageHandler.Context#processed()} are ignored.
120
120
*
121
- * <p>Consider using {@link #creditEveryNthChunk(int, int)} instead as it generates less network
122
- * traffic.
123
- *
124
121
* @param initialCredits number of initial credits
125
122
* @return flow strategy
126
123
* @see com.rabbitmq.stream.ConsumerBuilder.FlowConfiguration#initialCredits(int)
@@ -175,11 +172,12 @@ static ConsumerFlowStrategy creditOnProcessedMessageCount(int initialCredits, do
175
172
* Strategy that provides the specified number of initial credits and <code>n</code> credits every
176
173
* <code>n</code> chunks.
177
174
*
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>.
181
179
*
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.
183
181
*
184
182
* <p>Calls to {@link MessageHandler.Context#processed()} are ignored.
185
183
*
@@ -195,9 +193,10 @@ static ConsumerFlowStrategy creditEveryNthChunk(int initialCredits, int n) {
195
193
* Strategy that provides the specified number of initial credits and <code>n</code> credits every
196
194
* <code>n</code> chunks.
197
195
*
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>.
201
200
*
202
201
* <p>Calls to {@link MessageHandler.Context#processed()} are ignored.
203
202
*/
@@ -213,9 +212,9 @@ private CreditEveryNthChunkConsumerFlowStrategy(int initialCredits, int n) {
213
212
if (n <= 0 ) {
214
213
throw new IllegalArgumentException ("The n argument must be greater than 0" );
215
214
}
216
- if (initialCredits <= n ) {
215
+ if (n * 2 > initialCredits ) {
217
216
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 " );
219
218
}
220
219
this .initialCredits = initialCredits ;
221
220
this .n = n ;
0 commit comments