pulsar-client-cpp
|
#include <ConsumerConfiguration.h>
Friends | |
class | PulsarWrapper |
Class specifying the configuration of a consumer.
ConsumerConfiguration pulsar::ConsumerConfiguration::clone | ( | ) | const |
Create a new instance of ConsumerConfiguration with the same initial settings as the current one.
long pulsar::ConsumerConfiguration::getAckGroupingMaxSize | ( | ) | const |
Get max number of grouped messages within one grouping time window.
long pulsar::ConsumerConfiguration::getAckGroupingTimeMs | ( | ) | const |
Get grouping time window in milliseconds.
long pulsar::ConsumerConfiguration::getBrokerConsumerStatsCacheTimeInMs | ( | ) | const |
const std::string & pulsar::ConsumerConfiguration::getConsumerName | ( | ) | const |
ConsumerType pulsar::ConsumerConfiguration::getConsumerType | ( | ) | const |
ConsumerCryptoFailureAction pulsar::ConsumerConfiguration::getCryptoFailureAction | ( | ) | const |
const CryptoKeyReaderPtr pulsar::ConsumerConfiguration::getCryptoKeyReader | ( | ) | const |
KeySharedPolicy pulsar::ConsumerConfiguration::getKeySharedPolicy | ( | ) | const |
int pulsar::ConsumerConfiguration::getMaxTotalReceiverQueueSizeAcrossPartitions | ( | ) | const |
MessageListener pulsar::ConsumerConfiguration::getMessageListener | ( | ) | const |
long pulsar::ConsumerConfiguration::getNegativeAckRedeliveryDelayMs | ( | ) | const |
Get the configured delay to wait before re-delivering messages that have failed to be process.
int pulsar::ConsumerConfiguration::getPatternAutoDiscoveryPeriod | ( | ) | const |
std::map< std::string, std::string > & pulsar::ConsumerConfiguration::getProperties | ( | ) | const |
Get all the properties attached to this producer.
const std::string & pulsar::ConsumerConfiguration::getProperty | ( | const std::string & | name | ) | const |
Get the value of a specific property
name | the name of the property |
int pulsar::ConsumerConfiguration::getReceiverQueueSize | ( | ) | const |
const SchemaInfo & pulsar::ConsumerConfiguration::getSchema | ( | ) | const |
InitialPosition pulsar::ConsumerConfiguration::getSubscriptionInitialPosition | ( | ) | const |
InitialPosition
for the consumer long pulsar::ConsumerConfiguration::getTickDurationInMs | ( | ) | const |
long pulsar::ConsumerConfiguration::getUnAckedMessagesTimeoutMs | ( | ) | const |
bool pulsar::ConsumerConfiguration::hasMessageListener | ( | ) | const |
bool pulsar::ConsumerConfiguration::hasProperty | ( | const std::string & | name | ) | const |
Check whether the message has a specific property attached.
name | the name of the property to check |
bool pulsar::ConsumerConfiguration::isEncryptionEnabled | ( | ) | const |
bool pulsar::ConsumerConfiguration::isReadCompacted | ( | ) | const |
bool pulsar::ConsumerConfiguration::isReplicateSubscriptionStateEnabled | ( | ) | const |
void pulsar::ConsumerConfiguration::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.
maxGroupingSize | max number of grouped messages with in one grouping time window. |
void pulsar::ConsumerConfiguration::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.
ackGroupMillis | time of ACK grouping window in milliseconds. |
void pulsar::ConsumerConfiguration::setBrokerConsumerStatsCacheTimeInMs | ( | const long | cacheTimeInMs | ) |
Set the time duration for which the broker side consumer stats will be cached in the client.
Default: 30000, which means 30 seconds.
cacheTimeInMs | in milliseconds |
void pulsar::ConsumerConfiguration::setConsumerName | ( | const std::string & | consumerName | ) |
Set the consumer name.
consumerName |
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.
ConsumerConfiguration & pulsar::ConsumerConfiguration::setCryptoFailureAction | ( | ConsumerCryptoFailureAction | action | ) |
Set the ConsumerCryptoFailureAction.
ConsumerConfiguration & pulsar::ConsumerConfiguration::setCryptoKeyReader | ( | CryptoKeyReaderPtr | cryptoKeyReader | ) |
Set the shared pointer to CryptoKeyReader.
the | shared pointer to CryptoKeyReader |
ConsumerConfiguration & pulsar::ConsumerConfiguration::setKeySharedPolicy | ( | KeySharedPolicy | keySharedPolicy | ) |
Set KeyShared subscription policy for consumer.
By default, KeyShared subscription use auto split hash range to maintain consumers. If you want to set a different KeyShared policy, you can set by following example:
keySharedPolicy | The KeySharedPolicy want to specify |
void pulsar::ConsumerConfiguration::setMaxTotalReceiverQueueSizeAcrossPartitions | ( | int | maxTotalReceiverQueueSizeAcrossPartitions | ) |
Set the max total receiver queue size across partitons.
This setting is used to reduce the receiver queue size for individual partitions setReceiverQueueSize(int)
if the total exceeds this value (default: 50000).
maxTotalReceiverQueueSizeAcrossPartitions |
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.
void pulsar::ConsumerConfiguration::setNegativeAckRedeliveryDelayMs | ( | long | redeliveryDelayMillis | ) |
Set the delay to wait before re-delivering messages that have failed to be process.
When application uses Consumer#negativeAcknowledge(Message)
, the failed message will be redelivered after a fixed timeout. The default is 1 min.
redeliveryDelay | redelivery delay for failed messages |
timeUnit | unit in which the timeout is provided. |
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.
periodInSeconds | period in seconds to do an auto discovery |
ConsumerConfiguration & pulsar::ConsumerConfiguration::setProperties | ( | const std::map< std::string, std::string > & | properties | ) |
Add all the properties in the provided map
ConsumerConfiguration & pulsar::ConsumerConfiguration::setProperty | ( | const std::string & | name, |
const std::string & | value | ||
) |
Sets a new property on a message.
name | the name of the property |
value | the associated value |
void pulsar::ConsumerConfiguration::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.
readCompacted | whether to read from the compacted topic |
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 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 the most use cases.
size | the new receiver queue size value |
void pulsar::ConsumerConfiguration::setReplicateSubscriptionStateEnabled | ( | bool | enabled | ) |
Set whether the subscription status should be replicated. The default value is false
.
replicateSubscriptionState | whether the subscription status should be replicated |
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.
schemaInfo | the schema definition object |
void pulsar::ConsumerConfiguration::setSubscriptionInitialPosition | ( | InitialPosition | subscriptionInitialPosition | ) |
The default value is InitialPositionLatest
.
subscriptionInitialPosition | the initial position at which to set the cursor when subscribing to the topic for the first time |
void pulsar::ConsumerConfiguration::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.
milliSeconds | the tick duration time (in milliseconds) |
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.
Default: 0, which means the the tracker for unacknowledged messages is disabled.
timeout | in milliseconds |