pulsar-client-cpp
Public Member Functions | Friends | List of all members
pulsar::Producer Class Reference

Public Member Functions

 Producer ()
 
const std::string & getTopic () const
 
Result send (const Message &msg)
 
void sendAsync (const Message &msg, SendCallback callback)
 
Result close ()
 
void closeAsync (CloseCallback callback)
 

Friends

class ClientImpl
 
class PulsarFriend
 
class PulsarWrapper
 

Constructor & Destructor Documentation

◆ Producer()

pulsar::Producer::Producer ( )

Construct an uninitialized Producer.

Member Function Documentation

◆ close()

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.

Returns
an error code to indicate the success or failure

◆ closeAsync()

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.

◆ getTopic()

const std::string& pulsar::Producer::getTopic ( ) const
Returns
the topic to which producer is publishing to

◆ send()

Result pulsar::Producer::send ( const Message msg)

Publish a message on the topic associated with this Producer.

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.

Parameters
msgmessage to publish
Returns
ResultOk if the message was published successfully
ResultWriteError if it wasn't possible to publish the message

◆ sendAsync()

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.

Parameters
msgmessage to publish
callbackthe callback to get notification of the completion

The documentation for this class was generated from the following file: