pulsar-client-cpp
Loading...
Searching...
No Matches
MessageId.h
1
19#ifndef MESSAGE_ID_H
20#define MESSAGE_ID_H
21
22#include <pulsar/defines.h>
23#include <stdint.h>
24
25#include <iosfwd>
26#include <memory>
27#include <string>
28#include <vector>
29
30namespace pulsar {
31
32class MessageIdImpl;
33
34class PULSAR_PUBLIC MessageId {
35 public:
36 MessageId& operator=(const MessageId&);
37 MessageId();
38
51 explicit MessageId(int32_t partition, int64_t ledgerId, int64_t entryId, int32_t batchIndex);
52
56 static const MessageId& earliest();
57
61 static const MessageId& latest();
62
66 void serialize(std::string& result) const;
67
73 const std::string& getTopicName() const;
74
79 void setTopicName(const std::string& topicName);
80
84 static MessageId deserialize(const std::string& serializedMessageId);
85
86 // These functions compare the message order as stored in bookkeeper
87 bool operator<(const MessageId& other) const;
88 bool operator<=(const MessageId& other) const;
89 bool operator>(const MessageId& other) const;
90 bool operator>=(const MessageId& other) const;
91 bool operator==(const MessageId& other) const;
92 bool operator!=(const MessageId& other) const;
93
94 int64_t ledgerId() const;
95 int64_t entryId() const;
96 int32_t batchIndex() const;
97 int32_t partition() const;
98 int32_t batchSize() const;
99
100 private:
101 friend class ConsumerImpl;
102 friend class ReaderImpl;
103 friend class Message;
104 friend class MessageImpl;
105 friend class Commands;
106 friend class PartitionedProducerImpl;
107 friend class MultiTopicsConsumerImpl;
108 friend class UnAckedMessageTrackerEnabled;
109 friend class BatchAcknowledgementTracker;
110 friend class PulsarWrapper;
111 friend class PulsarFriend;
112 friend class NegativeAcksTracker;
113 friend class MessageIdBuilder;
114 friend class ChunkMessageIdImpl;
115
116 void setTopicName(const std::shared_ptr<std::string>& topic);
117
118 friend PULSAR_PUBLIC std::ostream& operator<<(std::ostream& s, const MessageId& messageId);
119
120 typedef std::shared_ptr<MessageIdImpl> MessageIdImplPtr;
121 MessageIdImplPtr impl_;
122
123 explicit MessageId(const MessageIdImplPtr& impl);
124};
125
126typedef std::vector<MessageId> MessageIdList;
127} // namespace pulsar
128
129#endif // MESSAGE_ID_H
Definition Message.h:44
Definition MessageIdBuilder.h:54
Definition MessageId.h:34
static MessageId deserialize(const std::string &serializedMessageId)
static const MessageId & earliest()
void setTopicName(const std::string &topicName)
const std::string & getTopicName() const
MessageId(int32_t partition, int64_t ledgerId, int64_t entryId, int32_t batchIndex)
void serialize(std::string &result) const
static const MessageId & latest()
Definition Authentication.h:31