pulsar-client-cpp
Loading...
Searching...
No Matches
Public Member Functions | List of all members
pulsar::ReaderConfiguration Class Reference

#include <ReaderConfiguration.h>

Public Member Functions

 ReaderConfiguration (const ReaderConfiguration &)
 
ReaderConfigurationoperator= (const ReaderConfiguration &)
 
ReaderConfigurationsetSchema (const SchemaInfo &schemaInfo)
 
const SchemaInfogetSchema () const
 
ReaderConfigurationsetReaderListener (ReaderListener listener)
 
ReaderListener getReaderListener () const
 
bool hasReaderListener () const
 
void setReceiverQueueSize (int size)
 
int getReceiverQueueSize () const
 
void setReaderName (const std::string &readerName)
 
const std::string & getReaderName () const
 
void setSubscriptionRolePrefix (const std::string &subscriptionRolePrefix)
 
const std::string & getSubscriptionRolePrefix () const
 
void setReadCompacted (bool compacted)
 
bool isReadCompacted () const
 
void setInternalSubscriptionName (std::string internalSubscriptionName)
 
const std::string & getInternalSubscriptionName () const
 
void setUnAckedMessagesTimeoutMs (const uint64_t milliSeconds)
 
long getUnAckedMessagesTimeoutMs () const
 
void setTickDurationInMs (const uint64_t milliSeconds)
 
long getTickDurationInMs () const
 
void setAckGroupingTimeMs (long ackGroupingMillis)
 
long getAckGroupingTimeMs () const
 
void setAckGroupingMaxSize (long maxGroupingSize)
 
long getAckGroupingMaxSize () const
 
bool isEncryptionEnabled () const
 
const CryptoKeyReaderPtr getCryptoKeyReader () const
 
ReaderConfigurationsetCryptoKeyReader (CryptoKeyReaderPtr cryptoKeyReader)
 
ConsumerCryptoFailureAction getCryptoFailureAction () const
 
ReaderConfigurationsetCryptoFailureAction (ConsumerCryptoFailureAction action)
 
ReaderConfigurationsetStartMessageIdInclusive (bool startMessageIdInclusive)
 
bool isStartMessageIdInclusive () const
 
bool hasProperty (const std::string &name) const
 
const std::string & getProperty (const std::string &name) const
 
std::map< std::string, std::string > & getProperties () const
 
ReaderConfigurationsetProperty (const std::string &name, const std::string &value)
 
ReaderConfigurationsetProperties (const std::map< std::string, std::string > &properties)
 

Detailed Description

Class specifying the configuration of a consumer.

Member Function Documentation

◆ getAckGroupingMaxSize()

long pulsar::ReaderConfiguration::getAckGroupingMaxSize ( ) const

Get max number of grouped messages within one grouping time window.

Returns
max number of grouped messages within one grouping time window.

◆ getAckGroupingTimeMs()

long pulsar::ReaderConfiguration::getAckGroupingTimeMs ( ) const

Get grouping time window in milliseconds.

Returns
grouping time window in milliseconds.

◆ getCryptoFailureAction()

ConsumerCryptoFailureAction pulsar::ReaderConfiguration::getCryptoFailureAction ( ) const
Returns
the ConsumerCryptoFailureAction

◆ getCryptoKeyReader()

const CryptoKeyReaderPtr pulsar::ReaderConfiguration::getCryptoKeyReader ( ) const
Returns
the shared pointer to CryptoKeyReader

◆ getInternalSubscriptionName()

const std::string & pulsar::ReaderConfiguration::getInternalSubscriptionName ( ) const
Returns
the internal subscription name

◆ getProperties()

std::map< std::string, std::string > & pulsar::ReaderConfiguration::getProperties ( ) const

Get all the properties attached to this producer.

◆ getProperty()

const std::string & pulsar::ReaderConfiguration::getProperty ( const std::string &  name) const

Get the value of a specific property

Parameters
namethe name of the property
Returns
the value of the property or null if the property was not defined

◆ getReaderListener()

ReaderListener pulsar::ReaderConfiguration::getReaderListener ( ) const
Returns
the configured ReaderListener for the reader

◆ getReaderName()

const std::string & pulsar::ReaderConfiguration::getReaderName ( ) const
Returns
the reader name

◆ getReceiverQueueSize()

int pulsar::ReaderConfiguration::getReceiverQueueSize ( ) const
Returns
the receiver queue size

◆ getSchema()

const SchemaInfo & pulsar::ReaderConfiguration::getSchema ( ) const
Returns
the schema information declared for this consumer

◆ getSubscriptionRolePrefix()

const std::string & pulsar::ReaderConfiguration::getSubscriptionRolePrefix ( ) const
Returns
the subscription role prefix

◆ getTickDurationInMs()

long pulsar::ReaderConfiguration::getTickDurationInMs ( ) const
Returns
the tick duration time (in milliseconds)

◆ getUnAckedMessagesTimeoutMs()

long pulsar::ReaderConfiguration::getUnAckedMessagesTimeoutMs ( ) const
Returns
the configured timeout in milliseconds for unacked messages.

◆ hasProperty()

bool pulsar::ReaderConfiguration::hasProperty ( const std::string &  name) const

Check whether the message has a specific property attached.

Parameters
namethe name of the property to check
Returns
true if the message has the specified property
false if the property is not defined

◆ hasReaderListener()

bool pulsar::ReaderConfiguration::hasReaderListener ( ) const
Returns
true if ReaderListener has been set

◆ isEncryptionEnabled()

bool pulsar::ReaderConfiguration::isEncryptionEnabled ( ) const
Returns
true if encryption keys are added

◆ isReadCompacted()

bool pulsar::ReaderConfiguration::isReadCompacted ( ) const
Returns
true if readCompacted is enabled

◆ isStartMessageIdInclusive()

bool pulsar::ReaderConfiguration::isStartMessageIdInclusive ( ) const

The associated getter of setStartMessageIdInclusive

◆ setAckGroupingMaxSize()

void pulsar::ReaderConfiguration::setAckGroupingMaxSize ( long  maxGroupingSize)

Set max number of grouped messages within one grouping time window. If it's set to a non-positive value, number of grouped messages is not limited. Default is 1000.

Parameters
maxGroupingSizemax number of grouped messages with in one grouping time window.

◆ setAckGroupingTimeMs()

void pulsar::ReaderConfiguration::setAckGroupingTimeMs ( long  ackGroupingMillis)

Set time window in milliseconds for grouping message ACK requests. An ACK request is not sent to broker until the time window reaches its end, or the number of grouped messages reaches limit. Default is 100 milliseconds. If it's set to a non-positive value, ACK requests will be directly sent to broker without grouping.

Parameters
ackGroupMillistime of ACK grouping window in milliseconds.

◆ setCryptoFailureAction()

ReaderConfiguration & pulsar::ReaderConfiguration::setCryptoFailureAction ( ConsumerCryptoFailureAction  action)

Set the CryptoFailureAction for the reader.

◆ setCryptoKeyReader()

ReaderConfiguration & pulsar::ReaderConfiguration::setCryptoKeyReader ( CryptoKeyReaderPtr  cryptoKeyReader)

Set the shared pointer to CryptoKeyReader.

Parameters
theshared pointer to CryptoKeyReader

◆ setInternalSubscriptionName()

void pulsar::ReaderConfiguration::setInternalSubscriptionName ( std::string  internalSubscriptionName)

Set the internal subscription name.

Parameters
internalsubscriptionName Default value is reader-{random string}.

◆ setProperties()

ReaderConfiguration & pulsar::ReaderConfiguration::setProperties ( const std::map< std::string, std::string > &  properties)

Add all the properties in the provided map

◆ setProperty()

ReaderConfiguration & pulsar::ReaderConfiguration::setProperty ( const std::string &  name,
const std::string &  value 
)

Sets a new property on a message.

Parameters
namethe name of the property
valuethe associated value

◆ setReadCompacted()

void pulsar::ReaderConfiguration::setReadCompacted ( bool  compacted)

If enabled, the consumer reads messages from the compacted topics rather than reading the full message backlog of the topic. This means that if the topic has been compacted, the consumer only sees the latest value for each key in the topic, up until the point in the topic message backlog that has been compacted. Beyond that point, message is sent as normal.

readCompacted can only be enabled subscriptions to persistent topics, which have a single active consumer (for example, failure or exclusive subscriptions). Attempting to enable it on subscriptions to a non-persistent topics or on a shared subscription leads to the subscription call failure.

Parameters
readCompactedwhether to read from the compacted topic

◆ setReaderListener()

ReaderConfiguration & pulsar::ReaderConfiguration::setReaderListener ( ReaderListener  listener)

A message listener enables your application to configure how to process messages. A listener will be called in order for every message received.

◆ setReaderName()

void pulsar::ReaderConfiguration::setReaderName ( const std::string &  readerName)

Set the reader name.

Parameters
readerName

◆ setReceiverQueueSize()

void pulsar::ReaderConfiguration::setReceiverQueueSize ( int  size)

Sets the size of the reader receive queue.

The consumer receive queue controls how many messages can be accumulated by the consumer before the application calls receive(). Using a higher value may potentially increase the consumer throughput at the expense of bigger memory utilization.

Setting the consumer queue size to 0 decreases the throughput of the consumer by disabling pre-fetching of messages. This approach improves the message distribution on shared subscription by pushing messages only to the consumers that are ready to process them. Neither receive with timeout nor partitioned topics can be used if the consumer queue size is 0. The receive() function call should not be interrupted when the consumer queue size is 0.

The default value is 1000 messages and it is appropriate for most use cases.

Parameters
sizethe new receiver queue size value

◆ setSchema()

ReaderConfiguration & pulsar::ReaderConfiguration::setSchema ( const SchemaInfo schemaInfo)

Declare the schema of the data that this reader will be accepting.

The schema will be checked against the schema of the topic, and the reader creation will fail if it's not compatible.

Parameters
schemaInfothe schema definition object

◆ setStartMessageIdInclusive()

ReaderConfiguration & pulsar::ReaderConfiguration::setStartMessageIdInclusive ( bool  startMessageIdInclusive)

Set the reader to include the startMessageId or given position of any reset operation like Reader::seek.

Default: false

Parameters
startMessageIdInclusivewhether to include the reset position

◆ setSubscriptionRolePrefix()

void pulsar::ReaderConfiguration::setSubscriptionRolePrefix ( const std::string &  subscriptionRolePrefix)

Set the subscription role prefix.

The default prefix is an empty string.

Parameters
subscriptionRolePrefix

◆ setTickDurationInMs()

void pulsar::ReaderConfiguration::setTickDurationInMs ( const uint64_t  milliSeconds)

Set the tick duration time that defines the granularity of the ack-timeout redelivery (in milliseconds).

The default value is 1000, which means 1 second.

Using a higher tick time reduces the memory overhead to track messages when the ack-timeout is set to a bigger value.

Parameters
milliSecondsthe tick duration time (in milliseconds)

◆ setUnAckedMessagesTimeoutMs()

void pulsar::ReaderConfiguration::setUnAckedMessagesTimeoutMs ( const uint64_t  milliSeconds)

Set the timeout in milliseconds for unacknowledged messages, the timeout needs to be greater than 10 seconds. An Exception is thrown if the given value is less than 10000 (10 seconds). If a successful acknowledgement is not sent within the timeout all the unacknowledged messages are redelivered.

Parameters
timeoutin milliseconds

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