pulsar-client-cpp
Loading...
Searching...
No Matches
Message.h
1
19#ifndef MESSAGE_HPP_
20#define MESSAGE_HPP_
21
22#include <map>
23#include <string>
24
25#include <memory>
26
27#include <pulsar/defines.h>
28#include "MessageId.h"
29
30namespace pulsar {
31namespace proto {
32class CommandMessage;
33class MessageMetadata;
34class SingleMessageMetadata;
35} // namespace proto
36
37class SharedBuffer;
38class MessageBuilder;
39class MessageImpl;
40class PulsarWrapper;
41
42class PULSAR_PUBLIC Message {
43 public:
44 typedef std::map<std::string, std::string> StringMap;
45
46 Message();
47
54 const StringMap& getProperties() const;
55
63 bool hasProperty(const std::string& name) const;
64
71 const std::string& getProperty(const std::string& name) const;
72
79 const void* getData() const;
80
86 std::size_t getLength() const;
87
93 std::string getDataAsString() const;
94
104 const MessageId& getMessageId() const;
105
110 void setMessageId(const MessageId& messageId) const;
111
116 const std::string& getPartitionKey() const;
117
121 bool hasPartitionKey() const;
122
128 const std::string& getOrderingKey() const;
129
136 bool hasOrderingKey() const;
137
142 uint64_t getPublishTimestamp() const;
143
147 uint64_t getEventTimestamp() const;
148
152 const std::string& getTopicName() const;
153
157 const int getRedeliveryCount() const;
158
162 bool hasSchemaVersion() const;
163
167 const std::string& getSchemaVersion() const;
168
169 bool operator==(const Message& msg) const;
170
171 private:
172 typedef std::shared_ptr<MessageImpl> MessageImplPtr;
173 MessageImplPtr impl_;
174
175 Message(MessageImplPtr& impl);
176 Message(const proto::CommandMessage& msg, proto::MessageMetadata& data, SharedBuffer& payload,
177 int32_t partition);
179 Message(const MessageId& messageId, proto::MessageMetadata& metadata, SharedBuffer& payload,
180 proto::SingleMessageMetadata& singleMetadata, const std::string& topicName);
181 friend class PartitionedProducerImpl;
182 friend class MultiTopicsConsumerImpl;
183 friend class MessageBuilder;
184 friend class ConsumerImpl;
185 friend class ProducerImpl;
186 friend class Commands;
187 friend class BatchMessageContainerBase;
188 friend class BatchAcknowledgementTracker;
189 friend class PulsarWrapper;
190 friend class MessageBatch;
191 friend struct OpSendMsg;
192
193 friend PULSAR_PUBLIC std::ostream& operator<<(std::ostream& s, const StringMap& map);
194 friend PULSAR_PUBLIC std::ostream& operator<<(std::ostream& s, const Message& msg);
195};
196} // namespace pulsar
197
198#endif /* MESSAGE_HPP_ */
Definition: MessageBatch.h:29
Definition: MessageBuilder.h:32
Definition: Message.h:42
const std::string & getPartitionKey() const
bool hasPartitionKey() const
void setMessageId(const MessageId &messageId) const
std::string getDataAsString() const
bool hasSchemaVersion() const
const std::string & getProperty(const std::string &name) const
uint64_t getEventTimestamp() const
std::size_t getLength() const
const std::string & getOrderingKey() const
const void * getData() const
uint64_t getPublishTimestamp() const
const std::string & getSchemaVersion() const
const int getRedeliveryCount() 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:32
Definition: Authentication.h:30