pulsar-client-cpp
Producer.h
1 
19 #ifndef PRODUCER_HPP_
20 #define PRODUCER_HPP_
21 
22 #include <pulsar/ProducerConfiguration.h>
23 #include <pulsar/defines.h>
24 #include <stdint.h>
25 
26 #include <memory>
27 
28 namespace pulsar {
29 class ProducerImplBase;
30 class PulsarWrapper;
31 class PulsarFriend;
32 
33 typedef std::function<void(Result)> FlushCallback;
34 typedef std::shared_ptr<ProducerImplBase> ProducerImplBasePtr;
35 
36 class PULSAR_PUBLIC Producer {
37  public:
41  Producer();
42 
46  const std::string& getTopic() const;
47 
51  const std::string& getProducerName() const;
52 
58  Result send(const Message& msg);
59 
84  Result send(const Message& msg, MessageId& messageId);
85 
100  void sendAsync(const Message& msg, SendCallback callback);
101 
106  Result flush();
107 
112  void flushAsync(FlushCallback callback);
113 
126  int64_t getLastSequenceId() const;
127 
136  const std::string& getSchemaVersion() const;
137 
147  Result close();
148 
156  void closeAsync(CloseCallback callback);
157 
161  bool isConnected() const;
162 
163  private:
164  explicit Producer(ProducerImplBasePtr);
165 
166  friend class ClientImpl;
167  friend class PulsarFriend;
168  friend class PulsarWrapper;
169  friend class ProducerImpl;
170 
171  ProducerImplBasePtr impl_;
172 
173  // For unit test case BatchMessageTest::producerFailureResult only
174  void producerFailMessages(Result result);
175 };
176 } // namespace pulsar
177 
178 #endif /* PRODUCER_HPP_ */
pulsar::MessageId
Definition: MessageId.h:34
pulsar::Result
Result
Definition: Result.h:31
pulsar::Message
Definition: Message.h:43
pulsar
Definition: Authentication.h:31
pulsar::Producer
Definition: Producer.h:36