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)
BatchingStrategy
addToBatch
in interface BatchingStrategy
exch
- The exchange.routKey
- The routing key.message
- The message.MessageBatch
), or null if not ready to release.public Date nextRelease()
nextRelease
in interface BatchingStrategy
public Collection<MessageBatch> releaseBatches()
BatchingStrategy
releaseBatches
in interface BatchingStrategy
public boolean canDebatch(MessageProperties properties)
BatchingStrategy
BatchingStrategy.deBatch(Message, Consumer)
.canDebatch
in interface BatchingStrategy
properties
- 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 BatchingStrategy
message
- the batched message.fragmentConsumer
- a consumer for each fragment.BatchingStrategy.canDebatch(MessageProperties)