pulsar-client-cpp
|
Public Member Functions | |
Producer () | |
const std::string & | getTopic () const |
const std::string & | getProducerName () const |
Result | send (const Message &msg) |
Result | send (const Message &msg, MessageId &messageId) |
void | sendAsync (const Message &msg, SendCallback callback) |
Result | flush () |
void | flushAsync (FlushCallback callback) |
int64_t | getLastSequenceId () const |
const std::string & | getSchemaVersion () const |
Result | close () |
void | closeAsync (CloseCallback callback) |
bool | isConnected () const |
Friends | |
class | ClientImpl |
class | PulsarFriend |
class | PulsarWrapper |
class | ProducerImpl |
pulsar::Producer::Producer | ( | ) |
Construct an uninitialized Producer.
Result pulsar::Producer::close | ( | ) |
Close the producer and release resources allocated.
No more writes will be accepted from this producer. Waits until all pending write requests are persisted. In case of errors, pending writes will not be retried.
void pulsar::Producer::closeAsync | ( | CloseCallback | callback | ) |
Close the producer and release resources allocated.
No more writes will be accepted from this producer. The provided callback will be triggered when all pending write requests are persisted. In case of errors, pending writes will not be retried.
Result pulsar::Producer::flush | ( | ) |
Flush all the messages buffered in the client and wait until all messages have been successfully persisted.
void pulsar::Producer::flushAsync | ( | FlushCallback | callback | ) |
Flush all the messages buffered in the client and wait until all messages have been successfully persisted.
int64_t pulsar::Producer::getLastSequenceId | ( | ) | const |
Get the last sequence id that was published by this producer.
This represent either the automatically assigned or custom sequence id (set on the MessageBuilder) that was published and acknowledged by the broker.
After recreating a producer with the same producer name, this will return the last message that was published in the previous producer session, or -1 if there no message was ever published.
const std::string & pulsar::Producer::getProducerName | ( | ) | const |
const std::string & pulsar::Producer::getSchemaVersion | ( | ) | const |
Return an identifier for the schema version that this producer was created with.
When the producer is created, if a schema info was passed, the broker will determine the version of the passed schema. This identifier should be treated as an opaque identifier. In particular, even though this is represented as a string, the version might not be ascii printable.
const std::string & pulsar::Producer::getTopic | ( | ) | const |
bool pulsar::Producer::isConnected | ( | ) | const |
msg
though msg
is const
. Publish a message on the topic associated with this Producer and get the associated MessageId.
This method will block until the message will be accepted and persisted by the broker. In case of errors, the client library will try to automatically recover and use a different broker.
If it wasn't possible to successfully publish the message within the sendTimeout, an error will be returned.
This method is equivalent to asyncSend() and wait until the callback is triggered.
[in] | msg | message to publish |
[out] | messageId | the message id assigned to the published message |
void pulsar::Producer::sendAsync | ( | const Message & | msg, |
SendCallback | callback | ||
) |
Asynchronously publish a message on the topic associated with this Producer.
This method will initiate the publish operation and return immediately. The provided callback will be triggered when the message has been be accepted and persisted by the broker. In case of errors, the client library will try to automatically recover and use a different broker.
If it wasn't possible to successfully publish the message within the sendTimeout, the callback will be triggered with a Result::WriteError code.
msg | message to publish |
callback | the callback to get notification of the completion |