pulsar-client-cpp
Loading...
Searching...
No Matches
Message.h
1
19#ifndef MESSAGE_HPP_
20#define MESSAGE_HPP_
21
22#include <pulsar/defines.h>
23
24#include <map>
25#include <memory>
26#include <string>
27
28#include "KeyValue.h"
29#include "MessageId.h"
30
31namespace pulsar {
32namespace proto {
33class CommandMessage;
34class BrokerEntryMetadata;
35class MessageMetadata;
36class SingleMessageMetadata;
37} // namespace proto
38
39class SharedBuffer;
40class MessageBuilder;
41class MessageImpl;
42class PulsarWrapper;
43
44class PULSAR_PUBLIC Message {
45 public:
46 typedef std::map<std::string, std::string> StringMap;
47
48 Message();
49
56 const StringMap& getProperties() const;
57
65 bool hasProperty(const std::string& name) const;
66
73 const std::string& getProperty(const std::string& name) const;
74
81 const void* getData() const;
82
88 std::size_t getLength() const;
89
98#if defined(_MSC_VER) && !defined(NDEBUG)
99 const std::string& getDataAsString() const;
100#else
101 std::string getDataAsString() const;
102#endif
103
110
120 const MessageId& getMessageId() const;
121
126 void setMessageId(const MessageId& messageId) const;
127
132 int64_t getIndex() const;
133
138 const std::string& getPartitionKey() const;
139
143 bool hasPartitionKey() const;
144
150 const std::string& getOrderingKey() const;
151
158 bool hasOrderingKey() const;
159
164 uint64_t getPublishTimestamp() const;
165
169 uint64_t getEventTimestamp() const;
170
174 const std::string& getTopicName() const;
175
179 const int getRedeliveryCount() const;
180
184 bool hasSchemaVersion() const;
185
191 int64_t getLongSchemaVersion() const;
192
196 const std::string& getSchemaVersion() const;
197
198 bool operator==(const Message& msg) const;
199
200 protected:
201 typedef std::shared_ptr<MessageImpl> MessageImplPtr;
202 MessageImplPtr impl_;
203
204 Message(MessageImplPtr& impl);
205 Message(const MessageId& messageId, proto::BrokerEntryMetadata& brokerEntryMetadata,
206 proto::MessageMetadata& metadata, SharedBuffer& payload);
208 Message(const MessageId& messageId, proto::BrokerEntryMetadata& brokerEntryMetadata,
209 proto::MessageMetadata& metadata, SharedBuffer& payload,
210 proto::SingleMessageMetadata& singleMetadata, const std::shared_ptr<std::string>& topicName);
211 friend class PartitionedProducerImpl;
212 friend class MultiTopicsConsumerImpl;
213 friend class MessageBuilder;
214 friend class ConsumerImpl;
215 friend class ProducerImpl;
216 friend class Commands;
217 friend class BatchMessageContainerBase;
218 friend class BatchAcknowledgementTracker;
219 friend class PulsarWrapper;
220 friend class MessageBatch;
221 friend struct OpSendMsg;
222
223 friend PULSAR_PUBLIC std::ostream& operator<<(std::ostream& s, const StringMap& map);
224 friend PULSAR_PUBLIC std::ostream& operator<<(std::ostream& s, const Message& msg);
225 friend class PulsarFriend;
226};
227} // namespace pulsar
228
229#endif /* MESSAGE_HPP_ */
Definition KeyValue.h:35
Definition MessageBatch.h:29
Definition MessageBuilder.h:33
Definition Message.h:44
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
const std::string & getProperty(const std::string &name) const
int64_t getIndex() const
uint64_t getEventTimestamp() const
Message(const MessageId &messageId, proto::BrokerEntryMetadata &brokerEntryMetadata, proto::MessageMetadata &metadata, SharedBuffer &payload, proto::SingleMessageMetadata &singleMetadata, const std::shared_ptr< std::string > &topicName)
Used for Batch Messages.
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:34
Definition Authentication.h:31