pulsar-client-cpp
Loading...
Searching...
No Matches
ProducerConfiguration.h
1
19#ifndef PULSAR_PRODUCERCONFIGURATION_H_
20#define PULSAR_PRODUCERCONFIGURATION_H_
21#include <pulsar/CompressionType.h>
22#include <pulsar/CryptoKeyReader.h>
23#include <pulsar/Message.h>
24#include <pulsar/MessageRoutingPolicy.h>
25#include <pulsar/ProducerCryptoFailureAction.h>
26#include <pulsar/ProducerInterceptor.h>
27#include <pulsar/Result.h>
28#include <pulsar/Schema.h>
29#include <pulsar/defines.h>
30
31#include <functional>
32#include <set>
33
34namespace pulsar {
35
36typedef std::function<void(Result, const MessageId& messageId)> SendCallback;
37typedef std::function<void(Result)> CloseCallback;
38
39struct ProducerConfigurationImpl;
40class PulsarWrapper;
41
45class PULSAR_PUBLIC ProducerConfiguration {
46 public:
47 enum PartitionsRoutingMode
48 {
49 UseSinglePartition,
50 RoundRobinDistribution,
51 CustomPartition
52 };
53 enum HashingScheme
54 {
55 Murmur3_32Hash,
56 BoostHash,
57 JavaStringHash
58 };
60 {
71
81 KeyBasedBatching
82 };
84 {
88 Shared = 0,
89
93 Exclusive = 1,
94
98 WaitForExclusive = 2,
99
104 ExclusiveWithFencing = 3
105 };
106
111
118 ProducerConfiguration& setProducerName(const std::string& producerName);
119
123 const std::string& getProducerName() const;
124
138
142 const SchemaInfo& getSchema() const;
143
148
159 int getSendTimeout() const;
160
172 ProducerConfiguration& setInitialSequenceId(int64_t initialSequenceId);
173
177 int64_t getInitialSequenceId() const;
178
194 ProducerConfiguration& setCompressionType(CompressionType compressionType);
195
199 CompressionType getCompressionType() const;
200
213
218
229 ProducerConfiguration& setMaxPendingMessagesAcrossPartitions(int maxPendingMessagesAcrossPartitions);
230
235
244 ProducerConfiguration& setPartitionsRoutingMode(const PartitionsRoutingMode& mode);
245
249 PartitionsRoutingMode getPartitionsRoutingMode() const;
250
257 ProducerConfiguration& setMessageRouter(const MessageRoutingPolicyPtr& router);
258
262 const MessageRoutingPolicyPtr& getMessageRouterPtr() const;
263
282 ProducerConfiguration& setHashingScheme(const HashingScheme& scheme);
283
287 HashingScheme getHashingScheme() const;
288
304
309
314
320
321 // Zero queue size feature will not be supported on consumer end if batching is enabled
322
338 ProducerConfiguration& setBatchingEnabled(const bool& batchingEnabled);
339
347 const bool& getBatchingEnabled() const;
348
360 ProducerConfiguration& setBatchingMaxMessages(const unsigned int& batchingMaxMessages);
361
365 const unsigned int& getBatchingMaxMessages() const;
366
380 const unsigned long& batchingMaxAllowedSizeInBytes);
381
385 const unsigned long& getBatchingMaxAllowedSizeInBytes() const;
386
394 ProducerConfiguration& setBatchingMaxPublishDelayMs(const unsigned long& batchingMaxPublishDelayMs);
395
399 const unsigned long& getBatchingMaxPublishDelayMs() const;
400
407
413
417 const CryptoKeyReaderPtr getCryptoKeyReader() const;
418
425 ProducerConfiguration& setCryptoKeyReader(CryptoKeyReaderPtr cryptoKeyReader);
426
430 ProducerCryptoFailureAction getCryptoFailureAction() const;
431
439 ProducerConfiguration& setCryptoFailureAction(ProducerCryptoFailureAction action);
440
444 const std::set<std::string>& getEncryptionKeys() const;
445
450
464
472 bool hasProperty(const std::string& name) const;
473
480 const std::string& getProperty(const std::string& name) const;
481
485 std::map<std::string, std::string>& getProperties() const;
486
493 ProducerConfiguration& setProperty(const std::string& name, const std::string& value);
494
498 ProducerConfiguration& setProperties(const std::map<std::string, std::string>& properties);
499
522
526 bool isChunkingEnabled() const;
527
536
541
542 ProducerConfiguration& intercept(const std::vector<ProducerInterceptorPtr>& interceptors);
543
544 const std::vector<ProducerInterceptorPtr>& getInterceptors() const;
545
546 private:
547 std::shared_ptr<ProducerConfigurationImpl> impl_;
548
549 friend class PulsarWrapper;
550 friend class ConsumerImpl;
551 friend class ProducerImpl;
552};
553} // namespace pulsar
554#endif /* PULSAR_PRODUCERCONFIGURATION_H_ */
Definition ProducerConfiguration.h:45
const std::string & getProperty(const std::string &name) const
const SchemaInfo & getSchema() const
ProducerConfiguration & setBatchingMaxMessages(const unsigned int &batchingMaxMessages)
ProducerConfiguration & setSendTimeout(int sendTimeoutMs)
ProducerConfiguration & setAccessMode(const ProducerAccessMode &accessMode)
const unsigned int & getBatchingMaxMessages() const
ProducerConfiguration & setBatchingMaxPublishDelayMs(const unsigned long &batchingMaxPublishDelayMs)
ProducerConfiguration & setCompressionType(CompressionType compressionType)
std::map< std::string, std::string > & getProperties() const
const CryptoKeyReaderPtr getCryptoKeyReader() const
ProducerConfiguration & setProperties(const std::map< std::string, std::string > &properties)
ProducerAccessMode getAccessMode() const
const std::string & getProducerName() const
ProducerConfiguration & setHashingScheme(const HashingScheme &scheme)
const std::set< std::string > & getEncryptionKeys() const
ProducerConfiguration & addEncryptionKey(std::string key)
CompressionType getCompressionType() const
ProducerConfiguration & setPartitionsRoutingMode(const PartitionsRoutingMode &mode)
ProducerConfiguration & setCryptoKeyReader(CryptoKeyReaderPtr cryptoKeyReader)
const unsigned long & getBatchingMaxAllowedSizeInBytes() const
bool hasProperty(const std::string &name) const
const MessageRoutingPolicyPtr & getMessageRouterPtr() const
ProducerConfiguration & setProducerName(const std::string &producerName)
ProducerCryptoFailureAction getCryptoFailureAction() const
ProducerConfiguration & setInitialSequenceId(int64_t initialSequenceId)
BatchingType getBatchingType() const
int64_t getInitialSequenceId() const
ProducerAccessMode
Definition ProducerConfiguration.h:84
ProducerConfiguration & setProperty(const std::string &name, const std::string &value)
int getMaxPendingMessagesAcrossPartitions() const
ProducerConfiguration & setBatchingMaxAllowedSizeInBytes(const unsigned long &batchingMaxAllowedSizeInBytes)
HashingScheme getHashingScheme() const
ProducerConfiguration & setBatchingType(BatchingType batchingType)
ProducerConfiguration & setMessageRouter(const MessageRoutingPolicyPtr &router)
ProducerConfiguration & setMaxPendingMessagesAcrossPartitions(int maxPendingMessagesAcrossPartitions)
ProducerConfiguration & setCryptoFailureAction(ProducerCryptoFailureAction action)
bool getLazyStartPartitionedProducers() const
const unsigned long & getBatchingMaxPublishDelayMs() const
ProducerConfiguration & setChunkingEnabled(bool chunkingEnabled)
BatchingType
Definition ProducerConfiguration.h:60
@ DefaultBatching
Definition ProducerConfiguration.h:70
const bool & getBatchingEnabled() const
ProducerConfiguration & setBlockIfQueueFull(bool)
PartitionsRoutingMode getPartitionsRoutingMode() const
ProducerConfiguration & setMaxPendingMessages(int maxPendingMessages)
ProducerConfiguration & setLazyStartPartitionedProducers(bool)
ProducerConfiguration & setSchema(const SchemaInfo &schemaInfo)
ProducerConfiguration & setBatchingEnabled(const bool &batchingEnabled)
Definition Schema.h:146
Definition Authentication.h:31
Result
Definition Result.h:32