pulsar-client-cpp
Message.h
1 
19 #ifndef MESSAGE_HPP_
20 #define MESSAGE_HPP_
21 
22 #include <map>
23 #include <string>
24 
25 #include <boost/shared_ptr.hpp>
26 #include "BatchMessageId.h"
27 
28 #pragma GCC visibility push(default)
29 
30 namespace pulsar {
31  namespace proto {
32  class CommandMessage;
33  class MessageMetadata;
34  class SingleMessageMetadata;
35  }
36 
37 class SharedBuffer;
38 class MessageBuilder;
39 class MessageImpl;
40 class PulsarWrapper;
41 
42 class 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 
103  const MessageId& getMessageId() const;
104 
109  const std::string& getPartitionKey() const;
110  bool hasPartitionKey() const;
111 
115  uint64_t getPublishTimestamp() const;
116 
117  private:
118  typedef boost::shared_ptr<MessageImpl> MessageImplPtr;
119  MessageImplPtr impl_;
120 
121  Message(MessageImplPtr& impl);
122  Message(const proto::CommandMessage& msg, proto::MessageMetadata& data, SharedBuffer& payload);
124  Message(const BatchMessageId& messageID, proto::MessageMetadata& metadata, SharedBuffer& payload, proto::SingleMessageMetadata& singleMetadata);
125  friend class PartitionedProducerImpl;
126  friend class PartitionedConsumerImpl;
127  friend class MessageBuilder;
128  friend class ConsumerImpl;
129  friend class ProducerImpl;
130  friend class Commands;
131  friend class BatchMessageContainer;
132  friend class BatchAcknowledgementTracker;
133  friend class PulsarWrapper;
134 
135  friend std::ostream& operator<<(std::ostream& s, const StringMap& map);
136  friend std::ostream& operator<<(std::ostream& s, const Message& msg);
137 };
138 
139 }
140 
141 #pragma GCC visibility pop
142 #endif /* MESSAGE_HPP_ */
Definition: MessageBuilder.h:30
Definition: Authentication.h:31
const std::string & getProperty(const std::string &name) const
std::size_t getLength() const
const StringMap & getProperties() const
Definition: Message.h:42
bool hasProperty(const std::string &name) const
Definition: BatchMessageId.h:26
const MessageId & getMessageId() const
const void * getData() const
std::string getDataAsString() const
Definition: MessageId.h:33
uint64_t getPublishTimestamp() const
const std::string & getPartitionKey() const