pulsar-client-cpp
Public Member Functions | Friends | List of all members
pulsar::ConsumerConfiguration Class Reference

#include <ConsumerConfiguration.h>

Public Member Functions

 ConsumerConfiguration (const ConsumerConfiguration &)
 
ConsumerConfiguration & operator= (const ConsumerConfiguration &)
 
ConsumerConfiguration & setSchema (const SchemaInfo &schemaInfo)
 
const SchemaInfo & getSchema () const
 
ConsumerConfiguration & setConsumerType (ConsumerType consumerType)
 
ConsumerType getConsumerType () const
 
ConsumerConfiguration & setMessageListener (MessageListener messageListener)
 
MessageListener getMessageListener () const
 
bool hasMessageListener () const
 
void setReceiverQueueSize (int size)
 
int getReceiverQueueSize () const
 
void setMaxTotalReceiverQueueSizeAcrossPartitions (int maxTotalReceiverQueueSizeAcrossPartitions)
 
int getMaxTotalReceiverQueueSizeAcrossPartitions () const
 
void setConsumerName (const std::string &)
 
const std::string & getConsumerName () const
 
void setUnAckedMessagesTimeoutMs (const uint64_t milliSeconds)
 
long getUnAckedMessagesTimeoutMs () const
 
void setBrokerConsumerStatsCacheTimeInMs (const long cacheTimeInMs)
 
long getBrokerConsumerStatsCacheTimeInMs () const
 
bool isEncryptionEnabled () const
 
const CryptoKeyReaderPtr getCryptoKeyReader () const
 
ConsumerConfiguration & setCryptoKeyReader (CryptoKeyReaderPtr cryptoKeyReader)
 
ConsumerCryptoFailureAction getCryptoFailureAction () const
 
ConsumerConfiguration & setCryptoFailureAction (ConsumerCryptoFailureAction action)
 
bool isReadCompacted () const
 
void setReadCompacted (bool compacted)
 
void setPatternAutoDiscoveryPeriod (int periodInSeconds)
 
int getPatternAutoDiscoveryPeriod () const
 
void setSubscriptionInitialPosition (InitialPosition subscriptionInitialPosition)
 
InitialPosition getSubscriptionInitialPosition () 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
 
ConsumerConfiguration & setProperty (const std::string &name, const std::string &value)
 
ConsumerConfiguration & setProperties (const std::map< std::string, std::string > &properties)
 

Friends

class PulsarWrapper
 

Detailed Description

Class specifying the configuration of a consumer.

Member Function Documentation

◆ getBrokerConsumerStatsCacheTimeInMs()

long pulsar::ConsumerConfiguration::getBrokerConsumerStatsCacheTimeInMs ( ) const
Returns
the configured timeout in milliseconds caching BrokerConsumerStats.

◆ getMaxTotalReceiverQueueSizeAcrossPartitions()

int pulsar::ConsumerConfiguration::getMaxTotalReceiverQueueSizeAcrossPartitions ( ) const
Returns
the configured max total receiver queue size across partitions

◆ getProperties()

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

Get all the properties attached to this producer.

◆ getProperty()

const std::string& pulsar::ConsumerConfiguration::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

◆ getSchema()

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

◆ getUnAckedMessagesTimeoutMs()

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

◆ hasProperty()

bool pulsar::ConsumerConfiguration::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

◆ setBrokerConsumerStatsCacheTimeInMs()

void pulsar::ConsumerConfiguration::setBrokerConsumerStatsCacheTimeInMs ( const long  cacheTimeInMs)

Set the time duration for which the broker side consumer stats will be cached in the client.

Parameters
cacheTimeInMsin milliseconds

◆ setConsumerType()

ConsumerConfiguration& pulsar::ConsumerConfiguration::setConsumerType ( ConsumerType  consumerType)

Specify the consumer type. The consumer type enables specifying the type of subscription. In Exclusive subscription, only a single consumer is allowed to attach to the subscription. Other consumers will get an error message. In Shared subscription, multiple consumers will be able to use the same subscription name and the messages will be dispatched in a round robin fashion. In Failover subscription, a primary-failover subscription model allows for multiple consumers to attach to a single subscription, though only one of them will be “master” at a given time. Only the primary consumer will receive messages. When the primary consumer gets disconnected, one among the failover consumers will be promoted to primary and will start getting messages.

◆ setMaxTotalReceiverQueueSizeAcrossPartitions()

void pulsar::ConsumerConfiguration::setMaxTotalReceiverQueueSizeAcrossPartitions ( int  maxTotalReceiverQueueSizeAcrossPartitions)

Set the max total receiver queue size across partitons.

This setting will be used to reduce the receiver queue size for individual partitions setReceiverQueueSize(int) if the total exceeds this value (default: 50000).

Parameters
maxTotalReceiverQueueSizeAcrossPartitions

◆ setMessageListener()

ConsumerConfiguration& pulsar::ConsumerConfiguration::setMessageListener ( MessageListener  messageListener)

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

◆ setPatternAutoDiscoveryPeriod()

void pulsar::ConsumerConfiguration::setPatternAutoDiscoveryPeriod ( int  periodInSeconds)

Set the time duration in minutes, for which the PatternMultiTopicsConsumer will do a pattern auto discovery. The default value is 60 seconds. less than 0 will disable auto discovery.

Parameters
periodInSecondsperiod in seconds to do an auto discovery

◆ setProperties()

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

Add all the properties in the provided map

◆ setProperty()

ConsumerConfiguration& pulsar::ConsumerConfiguration::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

◆ setReceiverQueueSize()

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

Sets the size of the consumer 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 could potentially increase the consumer throughput at the expense of bigger memory utilization.

Setting the consumer queue size as zero 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 zero. The receive() function call should not be interrupted when the consumer queue size is zero.

Default value is 1000 messages and should be good for most use cases.

Parameters
sizethe new receiver queue size value

◆ setSchema()

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

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

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

Parameters
schemaInfothe schema definition object

◆ setUnAckedMessagesTimeoutMs()

void pulsar::ConsumerConfiguration::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: