pulsar-client-cpp
Loading...
Searching...
No Matches
Message.h
1
19#ifndef MESSAGE_HPP_
20#define MESSAGE_HPP_
21
22#include <pulsar/EncryptionContext.h>
23#include <pulsar/defines.h>
24
25#include <map>
26#include <memory>
27#include <optional>
28#include <string>
29
30#include "KeyValue.h"
31#include "MessageId.h"
32
33namespace pulsar {
34namespace proto {
35class CommandMessage;
36class BrokerEntryMetadata;
37class MessageMetadata;
38class SingleMessageMetadata;
39} // namespace proto
40
41class SharedBuffer;
42class MessageBuilder;
43class MessageImpl;
44class PulsarWrapper;
45
46class PULSAR_PUBLIC Message {
47 public:
48 typedef std::map<std::string, std::string> StringMap;
49
50 Message();
51
58 const StringMap& getProperties() const;
59
67 bool hasProperty(const std::string& name) const;
68
75 const std::string& getProperty(const std::string& name) const;
76
83 const void* getData() const;
84
90 std::size_t getLength() const;
91
100#if defined(_MSC_VER) && !defined(NDEBUG)
101 const std::string& getDataAsString() const;
102#else
103 std::string getDataAsString() const;
104#endif
105
112
122 const MessageId& getMessageId() const;
123
128 void setMessageId(const MessageId& messageId) const;
129
134 int64_t getIndex() const;
135
140 const std::string& getPartitionKey() const;
141
145 bool hasPartitionKey() const;
146
152 const std::string& getOrderingKey() const;
153
160 bool hasOrderingKey() const;
161
166 uint64_t getPublishTimestamp() const;
167
171 uint64_t getEventTimestamp() const;
172
176 const std::string& getTopicName() const;
177
182
186 bool hasSchemaVersion() const;
187
193 int64_t getLongSchemaVersion() const;
194
198 const std::string& getSchemaVersion() const;
199
205 const std::string& getProducerName() const noexcept;
206
211 std::optional<const EncryptionContext*> getEncryptionContext() const;
212
213 bool operator==(const Message& msg) const;
214
215 protected:
216 typedef std::shared_ptr<MessageImpl> MessageImplPtr;
217 MessageImplPtr impl_;
218
219 Message(MessageImplPtr& impl);
220 Message(const MessageId& messageId, proto::BrokerEntryMetadata& brokerEntryMetadata,
221 proto::MessageMetadata& metadata, SharedBuffer& payload);
223 Message(const MessageId& messageId, proto::BrokerEntryMetadata& brokerEntryMetadata,
224 proto::MessageMetadata& metadata, SharedBuffer& payload,
225 proto::SingleMessageMetadata& singleMetadata, const std::shared_ptr<std::string>& topicName);
226 friend class PartitionedProducerImpl;
227 friend class MultiTopicsConsumerImpl;
228 friend class MessageBuilder;
229 friend class ConsumerImpl;
230 friend class ProducerImpl;
231 friend class Commands;
232 friend class BatchMessageContainerBase;
233 friend class BatchAcknowledgementTracker;
234 friend class PulsarWrapper;
235 friend class MessageBatch;
236 friend struct OpSendMsg;
237
238 friend PULSAR_PUBLIC std::ostream& operator<<(std::ostream& s, const StringMap& map);
239 friend PULSAR_PUBLIC std::ostream& operator<<(std::ostream& s, const Message& msg);
240 friend class PulsarFriend;
241};
242} // namespace pulsar
243
244#endif /* MESSAGE_HPP_ */
Definition EncryptionContext.h:49
Definition KeyValue.h:35
Definition MessageBuilder.h:33
const std::string & getPartitionKey() const
bool hasPartitionKey() const
KeyValue getKeyValueData() const
void setMessageId(const MessageId &messageId) const
std::string getDataAsString() const
int64_t getLongSchemaVersion() const
bool hasSchemaVersion() const
std::optional< const EncryptionContext * > getEncryptionContext() const
const std::string & getProperty(const std::string &name) const
int64_t getIndex() const
const std::string & getProducerName() const noexcept
uint64_t getEventTimestamp() const
int getRedeliveryCount() const
std::size_t getLength() const
const std::string & getOrderingKey() const
const void * getData() const
uint64_t getPublishTimestamp() const
const std::string & getSchemaVersion() const
bool hasOrderingKey() const
bool hasProperty(const std::string &name) const
const MessageId & getMessageId() const
const StringMap & getProperties() const
const std::string & getTopicName() const
Definition MessageId.h:34
Definition Authentication.h:31