Package com.rabbitmq.stream
Class ConsumerFlowStrategy.CreditEveryNthChunkConsumerFlowStrategy
- java.lang.Object
-
- com.rabbitmq.stream.ConsumerFlowStrategy.CreditEveryNthChunkConsumerFlowStrategy
-
- All Implemented Interfaces:
ConsumerFlowStrategy
- Enclosing interface:
- ConsumerFlowStrategy
public static final class ConsumerFlowStrategy.CreditEveryNthChunkConsumerFlowStrategy extends Object implements ConsumerFlowStrategy
Strategy that provides the specified number of initial credits andncredits everynchunks.This strategy can improve throughput for some workloads, it is possible to experiment with it if hitting problems with other flow strategies.
The number of initial credits must be at least twice as big as
n.Calls to
MessageHandler.Context.processed()are ignored.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.rabbitmq.stream.ConsumerFlowStrategy
ConsumerFlowStrategy.Context, ConsumerFlowStrategy.CreditEveryNthChunkConsumerFlowStrategy, ConsumerFlowStrategy.CreditOnChunkArrivalConsumerFlowStrategy, ConsumerFlowStrategy.MessageCountConsumerFlowStrategy, ConsumerFlowStrategy.MessageProcessedCallback
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intinitialCredits()The initial number of credits for a subscription.ConsumerFlowStrategy.MessageProcessedCallbackstart(ConsumerFlowStrategy.Context context)Return the behavior forMessageHandler.Context.processed()calls.
-
-
-
Method Detail
-
initialCredits
public int initialCredits()
Description copied from interface:ConsumerFlowStrategyThe initial number of credits for a subscription.It must be greater than 0. Values are usually between 1 and 10.
- Specified by:
initialCreditsin interfaceConsumerFlowStrategy- Returns:
- initial number of credits
-
start
public ConsumerFlowStrategy.MessageProcessedCallback start(ConsumerFlowStrategy.Context context)
Description copied from interface:ConsumerFlowStrategyReturn the behavior forMessageHandler.Context.processed()calls.This method is called for each chunk of messages. Implementations return a callback that will be called when applications consider a message dealt with and call
MessageHandler.Context.processed(). The callback can count messages and provide credits accordingly.- Specified by:
startin interfaceConsumerFlowStrategy- Parameters:
context- chunk context- Returns:
- the message processed callback
-
-