pulsar-client-cpp
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
pulsar::Reader Class Reference

#include <Reader.h>

Public Member Functions

 Reader ()
 
const std::string & getTopic () const
 
Result readNext (Message &msg)
 
Result readNext (Message &msg, int timeoutMs)
 
void readNextAsync (ReadNextCallback callback)
 
Result close ()
 
void closeAsync (ResultCallback callback)
 
void hasMessageAvailableAsync (HasMessageAvailableCallback callback)
 
Result hasMessageAvailable (bool &hasMessageAvailable)
 
Result seek (const MessageId &msgId)
 
Result seek (uint64_t timestamp)
 
void seekAsync (const MessageId &msgId, ResultCallback callback)
 
void seekAsync (uint64_t timestamp, ResultCallback callback)
 
bool isConnected () const
 
void getLastMessageIdAsync (GetLastMessageIdCallback callback)
 
Result getLastMessageId (MessageId &messageId)
 

Friends

class PulsarFriend
 
class PulsarWrapper
 
class ReaderImpl
 
class TableViewImpl
 
class ReaderTest
 

Detailed Description

A Reader can be used to scan through all the messages currently available in a topic.

Constructor & Destructor Documentation

◆ Reader()

pulsar::Reader::Reader ( )

Construct an uninitialized reader object

Member Function Documentation

◆ close()

Result pulsar::Reader::close ( )

Close the reader and stop the broker to push more messages

Returns
ResultOk if the reader is closed successfully

◆ closeAsync()

void pulsar::Reader::closeAsync ( ResultCallback  callback)

Asynchronously close the reader and stop the broker to push more messages

Parameters
callbackthe callback that is triggered when the reader is closed

◆ getLastMessageId()

Result pulsar::Reader::getLastMessageId ( MessageId messageId)

Get an ID of the last available message or a message ID with -1 as an entryId if the topic is empty.

◆ getLastMessageIdAsync()

void pulsar::Reader::getLastMessageIdAsync ( GetLastMessageIdCallback  callback)

Asynchronously get an ID of the last available message or a message ID with -1 as an entryId if the topic is empty.

◆ getTopic()

const std::string & pulsar::Reader::getTopic ( ) const
Returns
the topic this reader is reading from

◆ hasMessageAvailable()

Result pulsar::Reader::hasMessageAvailable ( bool &  hasMessageAvailable)

Check if there is any message available to read from the current position.

◆ hasMessageAvailableAsync()

void pulsar::Reader::hasMessageAvailableAsync ( HasMessageAvailableCallback  callback)

Asynchronously check if there is any message available to read from the current position.

◆ isConnected()

bool pulsar::Reader::isConnected ( ) const
Returns
Whether the reader is currently connected to the broker

◆ readNext() [1/2]

Result pulsar::Reader::readNext ( Message msg)

Read a single message.

If a message is not immediately available, this method will block until a new message is available.

Parameters
msga non-const reference where the received message will be copied
Returns
ResultOk when a message is received
ResultInvalidConfiguration if a message listener had been set in the configuration

◆ readNext() [2/2]

Result pulsar::Reader::readNext ( Message msg,
int  timeoutMs 
)

Read a single message

Parameters
msga non-const reference where the received message will be copied
timeoutMsthe receive timeout in milliseconds
Returns
ResultOk if a message was received
ResultTimeout if the receive timeout was triggered
ResultInvalidConfiguration if a message listener had been set in the configuration

◆ readNextAsync()

void pulsar::Reader::readNextAsync ( ReadNextCallback  callback)

Read asynchronously the next message in the topic.

Parameters
callback

◆ seek() [1/2]

Result pulsar::Reader::seek ( const MessageId msgId)

Reset the this reader to a specific message id. The message id can either be a specific message or represent the first or last messages in the topic.

Note: this operation can only be done on non-partitioned topics. For these, one can rather perform the seek() on the individual partitions.

Parameters
messageIdthe message id where to reposition the subscription

◆ seek() [2/2]

Result pulsar::Reader::seek ( uint64_t  timestamp)

Reset this reader to a specific message publish time.

Parameters
timestampthe message publish time where to reposition the subscription

◆ seekAsync() [1/2]

void pulsar::Reader::seekAsync ( const MessageId msgId,
ResultCallback  callback 
)

Asynchronously reset this reader to a specific message id. The message id can either be a specific message or represent the first or last messages in the topic.

Note: this operation can only be done on non-partitioned topics. For these, one can rather perform the seek() on the individual partitions.

Parameters
messageIdthe message id where to reposition the subscription

◆ seekAsync() [2/2]

void pulsar::Reader::seekAsync ( uint64_t  timestamp,
ResultCallback  callback 
)

Asynchronously reset this reader to a specific message publish time.

Parameters
timestampthe message publish time where to reposition the subscription

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