pulsar-client-cpp
|
#include <BatchReceivePolicy.h>
Public Member Functions | |
BatchReceivePolicy () | |
BatchReceivePolicy (int maxNumMessage, long maxNumBytes, long timeoutMs) | |
long | getTimeoutMs () const |
int | getMaxNumMessages () const |
long | getMaxNumBytes () const |
Configuration for message batch receive 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.
A batch receive action is completed as long as any one of the conditions (the batch has enough number or size of messages, or the waiting timeout is passed) are 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 wait for 100ms no matter whether there are enough messages.
Note: Must specify messages limitation(maxNumMessages, maxNumBytes) or wait timeout. Otherwise, Messages
ingest Message
will never end.
pulsar::BatchReceivePolicy::BatchReceivePolicy | ( | ) |
Default value: {maxNumMessage: -1, maxNumBytes: 10 * 1024 * 1024, timeoutMs: 100}
pulsar::BatchReceivePolicy::BatchReceivePolicy | ( | int | maxNumMessage, |
long | maxNumBytes, | ||
long | timeoutMs | ||
) |
maxNumMessage | Max num message, a non-positive value means no limit. |
maxNumBytes | Max num bytes, a non-positive value means no limit. |
timeoutMs | The receive timeout, a non-positive value means no limit. |
std::invalid_argument | if all arguments are non-positive |
long pulsar::BatchReceivePolicy::getMaxNumBytes | ( | ) | const |
Get max num bytes.
int pulsar::BatchReceivePolicy::getMaxNumMessages | ( | ) | const |
Get the maximum number of messages.
long pulsar::BatchReceivePolicy::getTimeoutMs | ( | ) | const |
Get max time out ms.