public class SimpleBatchingStrategy extends Object implements BatchingStrategy
| Constructor and Description |
|---|
SimpleBatchingStrategy(int batchSize,
int bufferLimit,
long timeout) |
| Modifier and Type | Method and Description |
|---|---|
MessageBatch |
addToBatch(String exch,
String routKey,
Message message)
Add a message to the batch and optionally release the batch.
|
boolean |
canDebatch(MessageProperties properties)
Return true if this strategy can decode a batch of messages from a message body.
|
void |
deBatch(Message message,
Consumer<Message> fragmentConsumer)
Debatch a message that has a header with
MessageProperties.SPRING_BATCH_FORMAT
set to MessageProperties.BATCH_FORMAT_LENGTH_HEADER4. |
Date |
nextRelease() |
Collection<MessageBatch> |
releaseBatches()
Release batch(es), perhaps due to a timeout.
|
public SimpleBatchingStrategy(int batchSize,
int bufferLimit,
long timeout)
batchSize - the batch size.bufferLimit - the max buffer size; could trigger a short batch. Does not apply
to a single message.timeout - the batch timeout.public MessageBatch addToBatch(String exch, String routKey, Message message)
BatchingStrategyaddToBatch in interface BatchingStrategyexch - The exchange.routKey - The routing key.message - The message.MessageBatch), or null if not ready to release.public Date nextRelease()
nextRelease in interface BatchingStrategypublic Collection<MessageBatch> releaseBatches()
BatchingStrategyreleaseBatches in interface BatchingStrategypublic boolean canDebatch(MessageProperties properties)
BatchingStrategyBatchingStrategy.deBatch(Message, Consumer).canDebatch in interface BatchingStrategyproperties - the message properties.BatchingStrategy.deBatch(Message, Consumer)public void deBatch(Message message, Consumer<Message> fragmentConsumer)
MessageProperties.SPRING_BATCH_FORMAT
set to MessageProperties.BATCH_FORMAT_LENGTH_HEADER4.deBatch in interface BatchingStrategymessage - the batched message.fragmentConsumer - a consumer for each fragment.BatchingStrategy.canDebatch(MessageProperties)