No Matches
Public Member Functions | List of all members
pulsar::BatchReceivePolicy Class Reference

#include <BatchReceivePolicy.h>

Public Member Functions

 BatchReceivePolicy ()
 BatchReceivePolicy (int maxNumMessage, long maxNumBytes, long timeoutMs)
long getTimeoutMs () const
int getMaxNumMessages () const
long getMaxNumBytes () const

Detailed Description

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.


Constructor & Destructor Documentation

◆ BatchReceivePolicy() [1/2]

pulsar::BatchReceivePolicy::BatchReceivePolicy ( )

Default value: {maxNumMessage: -1, maxNumBytes: 10 * 1024 * 1024, timeoutMs: 100}

◆ BatchReceivePolicy() [2/2]

pulsar::BatchReceivePolicy::BatchReceivePolicy ( int  maxNumMessage,
long  maxNumBytes,
long  timeoutMs 
maxNumMessageMax num message, a non-positive value means no limit.
maxNumBytesMax num bytes, a non-positive value means no limit.
timeoutMsThe receive timeout, a non-positive value means no limit.
std::invalid_argumentif all arguments are non-positive

Member Function Documentation

◆ getMaxNumBytes()

long pulsar::BatchReceivePolicy::getMaxNumBytes ( ) const

Get max num bytes.


◆ getMaxNumMessages()

int pulsar::BatchReceivePolicy::getMaxNumMessages ( ) const

Get the maximum number of messages.


◆ getTimeoutMs()

long pulsar::BatchReceivePolicy::getTimeoutMs ( ) const

Get max time out ms.


The documentation for this class was generated from the following file: