public class BatchReceivePolicy extends Object implements Serializable
Consumer.batchReceive()
Consumer.batchReceiveAsync()
.
Batch receive policy can limit the number and bytes of messages in a single batch, and can specify a timeout for waiting for enough messages for this batch.
This batch receive will be completed as long as any one of the conditions(has enough number of messages, has enough of size of messages, wait timeout) is met.
Examples:
1.If set maxNumMessages = 10, maxSizeOfMessages = 1MB and without timeout, it
means Consumer.batchReceive()
will always wait until there is enough messages.
2.If set maxNumberOfMessages = 0, maxNumBytes = 0 and timeout = 100ms, it
means Consumer.batchReceive()
will waiting for 100ms whether or not there is enough messages.
Note:
Must specify messages limitation(maxNumMessages, maxNumBytes) or wait timeout.
Otherwise, Messages
ingest Message
will never end.
Modifier and Type | Class and Description |
---|---|
static class |
BatchReceivePolicy.Builder
Builder of BatchReceivePolicy.
|
Modifier and Type | Field and Description |
---|---|
static BatchReceivePolicy |
DEFAULT_POLICY
Default batch receive policy.
|
Modifier and Type | Method and Description |
---|---|
static BatchReceivePolicy.Builder |
builder() |
long |
getMaxNumBytes() |
int |
getMaxNumMessages() |
long |
getTimeoutMs() |
String |
toString() |
void |
verify() |
public static final BatchReceivePolicy DEFAULT_POLICY
Max number of messages: no limit Max number of bytes: 10MB Timeout: 100ms
public void verify()
public long getTimeoutMs()
public int getMaxNumMessages()
public long getMaxNumBytes()
public static BatchReceivePolicy.Builder builder()
Copyright © 2017–2020 Apache Software Foundation. All rights reserved.