pulsar-client-cpp
Loading...
Searching...
No Matches
ConsumerConfiguration.h
1
19#ifndef PULSAR_CONSUMERCONFIGURATION_H_
20#define PULSAR_CONSUMERCONFIGURATION_H_
21
22#include <functional>
23#include <memory>
24#include <pulsar/defines.h>
25#include <pulsar/Result.h>
26#include <pulsar/ConsumerType.h>
27#include <pulsar/Message.h>
28#include <pulsar/Schema.h>
29#include <pulsar/ConsumerCryptoFailureAction.h>
30#include <pulsar/CryptoKeyReader.h>
31#include <pulsar/InitialPosition.h>
32#include <pulsar/KeySharedPolicy.h>
33#include <pulsar/ConsumerEventListener.h>
34#include "BatchReceivePolicy.h"
35
36namespace pulsar {
37
38class Consumer;
39class PulsarWrapper;
40
42typedef std::vector<Message> Messages;
43typedef std::function<void(Result result)> ResultCallback;
44typedef std::function<void(Result, const Message& msg)> ReceiveCallback;
45typedef std::function<void(Result, const Messages& msgs)> BatchReceiveCallback;
46typedef std::function<void(Result result, MessageId messageId)> GetLastMessageIdCallback;
47
49typedef std::function<void(Consumer consumer, const Message& msg)> MessageListener;
50
51typedef std::shared_ptr<ConsumerEventListener> ConsumerEventListenerPtr;
52
53struct ConsumerConfigurationImpl;
54
58class PULSAR_PUBLIC ConsumerConfiguration {
59 public:
64
70
80
84 const SchemaInfo& getSchema() const;
85
99
104
114
119
126
131
135 bool hasMessageListener() const;
136
141 ConsumerConfiguration& setConsumerEventListener(ConsumerEventListenerPtr eventListener);
142
146 ConsumerEventListenerPtr getConsumerEventListener() const;
147
152
174 void setReceiverQueueSize(int size);
175
180
189 void setMaxTotalReceiverQueueSizeAcrossPartitions(int maxTotalReceiverQueueSizeAcrossPartitions);
190
195
201 void setConsumerName(const std::string& consumerName);
202
206 const std::string& getConsumerName() const;
207
218 void setUnAckedMessagesTimeoutMs(const uint64_t milliSeconds);
219
224
236 void setTickDurationInMs(const uint64_t milliSeconds);
237
242
255 void setNegativeAckRedeliveryDelayMs(long redeliveryDelayMillis);
256
263
272 void setAckGroupingTimeMs(long ackGroupingMillis);
273
280
287 void setAckGroupingMaxSize(long maxGroupingSize);
288
295
303 void setBrokerConsumerStatsCacheTimeInMs(const long cacheTimeInMs);
304
309
314
318 const CryptoKeyReaderPtr getCryptoKeyReader() const;
319
325 ConsumerConfiguration& setCryptoKeyReader(CryptoKeyReaderPtr cryptoKeyReader);
326
330 ConsumerCryptoFailureAction getCryptoFailureAction() const;
331
335 ConsumerConfiguration& setCryptoFailureAction(ConsumerCryptoFailureAction action);
336
340 bool isReadCompacted() const;
341
355 void setReadCompacted(bool compacted);
356
364 void setPatternAutoDiscoveryPeriod(int periodInSeconds);
365
370
377 void setSubscriptionInitialPosition(InitialPosition subscriptionInitialPosition);
378
382 InitialPosition getSubscriptionInitialPosition() const;
383
390 void setBatchReceivePolicy(const BatchReceivePolicy& batchReceivePolicy);
391
398
406
411
419 bool hasProperty(const std::string& name) const;
420
427 const std::string& getProperty(const std::string& name) const;
428
432 std::map<std::string, std::string>& getProperties() const;
433
439 ConsumerConfiguration& setProperty(const std::string& name, const std::string& value);
440
444 ConsumerConfiguration& setProperties(const std::map<std::string, std::string>& properties);
445
449 std::map<std::string, std::string>& getSubscriptionProperties() const;
450
459 const std::map<std::string, std::string>& subscriptionProperties);
460
468
472 int getPriorityLevel() const;
473
495 ConsumerConfiguration& setMaxPendingChunkedMessage(size_t maxPendingChunkedMessage);
496
501
513 bool autoAckOldestChunkedMessageOnQueueFull);
514
519
527 ConsumerConfiguration& setStartMessageIdInclusive(bool startMessageIdInclusive);
528
533
534 friend class PulsarWrapper;
535
536 private:
537 std::shared_ptr<ConsumerConfigurationImpl> impl_;
538};
539} // namespace pulsar
540#endif /* PULSAR_CONSUMERCONFIGURATION_H_ */
Definition: BatchReceivePolicy.h:51
Definition: ConsumerConfiguration.h:58
ConsumerConfiguration & setProperties(const std::map< std::string, std::string > &properties)
ConsumerConfiguration & setPriorityLevel(int priorityLevel)
ConsumerType getConsumerType() const
long getBrokerConsumerStatsCacheTimeInMs() const
void setReceiverQueueSize(int size)
MessageListener getMessageListener() const
ConsumerCryptoFailureAction getCryptoFailureAction() const
long getUnAckedMessagesTimeoutMs() const
ConsumerConfiguration & setAutoAckOldestChunkedMessageOnQueueFull(bool autoAckOldestChunkedMessageOnQueueFull)
void setBrokerConsumerStatsCacheTimeInMs(const long cacheTimeInMs)
size_t getMaxPendingChunkedMessage() const
bool isReplicateSubscriptionStateEnabled() const
bool isAutoAckOldestChunkedMessageOnQueueFull() const
ConsumerConfiguration & setConsumerType(ConsumerType consumerType)
int getPatternAutoDiscoveryPeriod() const
ConsumerConfiguration & setKeySharedPolicy(KeySharedPolicy keySharedPolicy)
void setBatchReceivePolicy(const BatchReceivePolicy &batchReceivePolicy)
void setPatternAutoDiscoveryPeriod(int periodInSeconds)
void setAckGroupingMaxSize(long maxGroupingSize)
std::map< std::string, std::string > & getProperties() const
InitialPosition getSubscriptionInitialPosition() const
ConsumerConfiguration & setConsumerEventListener(ConsumerEventListenerPtr eventListener)
const CryptoKeyReaderPtr getCryptoKeyReader() const
void setReplicateSubscriptionStateEnabled(bool enabled)
ConsumerConfiguration & setSchema(const SchemaInfo &schemaInfo)
long getNegativeAckRedeliveryDelayMs() const
bool hasProperty(const std::string &name) const
const std::string & getProperty(const std::string &name) const
void setTickDurationInMs(const uint64_t milliSeconds)
const BatchReceivePolicy & getBatchReceivePolicy() const
bool isStartMessageIdInclusive() const
ConsumerConfiguration & setMessageListener(MessageListener messageListener)
void setConsumerName(const std::string &consumerName)
void setMaxTotalReceiverQueueSizeAcrossPartitions(int maxTotalReceiverQueueSizeAcrossPartitions)
ConsumerConfiguration & setMaxPendingChunkedMessage(size_t maxPendingChunkedMessage)
ConsumerConfiguration & setCryptoKeyReader(CryptoKeyReaderPtr cryptoKeyReader)
std::map< std::string, std::string > & getSubscriptionProperties() const
ConsumerConfiguration & setCryptoFailureAction(ConsumerCryptoFailureAction action)
void setSubscriptionInitialPosition(InitialPosition subscriptionInitialPosition)
bool hasConsumerEventListener() const
int getMaxTotalReceiverQueueSizeAcrossPartitions() const
ConsumerConfiguration & setProperty(const std::string &name, const std::string &value)
const SchemaInfo & getSchema() const
void setUnAckedMessagesTimeoutMs(const uint64_t milliSeconds)
ConsumerEventListenerPtr getConsumerEventListener() const
KeySharedPolicy getKeySharedPolicy() const
void setReadCompacted(bool compacted)
ConsumerConfiguration clone() const
ConsumerConfiguration & setSubscriptionProperties(const std::map< std::string, std::string > &subscriptionProperties)
void setNegativeAckRedeliveryDelayMs(long redeliveryDelayMillis)
const std::string & getConsumerName() const
void setAckGroupingTimeMs(long ackGroupingMillis)
ConsumerConfiguration & setStartMessageIdInclusive(bool startMessageIdInclusive)
Definition: Consumer.h:35
Definition: KeySharedPolicy.h:53
Definition: Message.h:42
Definition: MessageId.h:32
Definition: Schema.h:123
Definition: Authentication.h:30
std::function< void(Consumer consumer, const Message &msg)> MessageListener
Callback definition for MessageListener.
Definition: ConsumerConfiguration.h:49
ConsumerType
Definition: ConsumerType.h:24
std::vector< Message > Messages
Callback definition for non-data operation.
Definition: ConsumerConfiguration.h:42
std::function< void(Result result)> ResultCallback
Callback definition for non-data operation.
Definition: ConsumerConfiguration.h:43
Result
Definition: Result.h:31