pulsar-client-cpp
|
Public Member Functions | |
Consumer () | |
const std::string & | getTopic () const |
const std::string & | getSubscriptionName () const |
Result | unsubscribe () |
void | unsubscribeAsync (ResultCallback callback) |
Result | receive (Message &msg) |
Result | receive (Message &msg, int timeoutMs) |
Result | acknowledge (const Message &message) |
Result | acknowledge (const MessageId &messageId) |
void | acknowledgeAsync (const Message &message, ResultCallback callback) |
void | acknowledgeAsync (const MessageId &messageID, ResultCallback callback) |
Result | acknowledgeCumulative (const Message &message) |
Result | acknowledgeCumulative (const MessageId &messageId) |
void | acknowledgeCumulativeAsync (const Message &message, ResultCallback callback) |
void | acknowledgeCumulativeAsync (const MessageId &messageId, ResultCallback callback) |
Result | close () |
void | closeAsync (ResultCallback callback) |
Result | pauseMessageListener () |
Result | resumeMessageListener () |
void | redeliverUnacknowledgedMessages () |
Result | getBrokerConsumerStats (BrokerConsumerStats &brokerConsumerStats) |
void | getBrokerConsumerStatsAsync (BrokerConsumerStatsCallback callback) |
Friends | |
class | PulsarFriend |
class | PulsarWrapper |
class | PartitionedConsumerImpl |
class | ConsumerImpl |
class | ClientImpl |
class | ConsumerTest |
pulsar::Consumer::Consumer | ( | ) |
Construct an uninitialized consumer object
Acknowledge the reception of a single message.
This method will block until an acknowledgement is sent to the broker. After that, the message will not be re-delivered to this consumer.
message | the message to acknowledge |
void pulsar::Consumer::acknowledgeAsync | ( | const Message & | message, |
ResultCallback | callback | ||
) |
Asynchronously acknowledge the reception of a single message.
This method will initiate the operation and return immediately. The provided callback will be triggered when the operation is complete.
message | the message to acknowledge |
callback | callback that will be triggered when the message has been acknowledged |
Acknowledge the reception of all the messages in the stream up to (and including) the provided message.
This method will block until an acknowledgement is sent to the broker. After that, the messages will not be re-delivered to this consumer.
Cumulative acknowledge cannot be used when the consumer type is set to ConsumerShared.
It's equivalent to calling asyncAcknowledgeCumulative(const Message&, ResultCallback) and waiting for the callback to be triggered.
message | the last message in the stream to acknowledge |
void pulsar::Consumer::acknowledgeCumulativeAsync | ( | const Message & | message, |
ResultCallback | callback | ||
) |
Asynchronously acknowledge the reception of all the messages in the stream up to (and including) the provided message.
This method will initiate the operation and return immediately. The provided callback will be triggered when the operation is complete.
message | the message to acknowledge |
callback | callback that will be triggered when the message has been acknowledged |
Result pulsar::Consumer::getBrokerConsumerStats | ( | BrokerConsumerStats & | brokerConsumerStats | ) |
Gets Consumer Stats from broker. The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call expires then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the stats are still valid.
brokerConsumerStats | - if the function returns ResultOk, this object will contain consumer stats |
void pulsar::Consumer::getBrokerConsumerStatsAsync | ( | BrokerConsumerStatsCallback | callback | ) |
Asynchronous call to gets Consumer Stats from broker. The stats are cached for 30 seconds, if a call is made before the stats returned by the previous call expires then cached data will be returned. BrokerConsumerStats::isValid() function can be used to check if the stats are still valid.
callback | - callback function to get the brokerConsumerStats, if result is ResultOk then the brokerConsumerStats will be populated |
const std::string& pulsar::Consumer::getSubscriptionName | ( | ) | const |
const std::string& pulsar::Consumer::getTopic | ( | ) | const |
Receive a single message.
If a message is not immediately available, this method will block until a new message is available.
msg | a non-const reference where the received message will be copied |
msg | a non-const reference where the received message will be copied |
timeoutMs | the receive timeout in milliseconds |
void pulsar::Consumer::redeliverUnacknowledgedMessages | ( | ) |
Redelivers all the unacknowledged messages. In Failover mode, the request is ignored if the consumer is not active for the given topic. In Shared mode, the consumers messages to be redelivered are distributed across all the connected consumers. This is a non blocking call and doesn't throw an exception. In case the connection breaks, the messages are redelivered after reconnect.
Result pulsar::Consumer::unsubscribe | ( | ) |
Unsubscribe the current consumer from the topic.
This method will block until the operation is completed. Once the consumer is unsubscribed, no more messages will be received and subsequent new messages will not be retained for this consumer.
This consumer object cannot be reused.
void pulsar::Consumer::unsubscribeAsync | ( | ResultCallback | callback | ) |
Asynchronously unsubscribe the current consumer from the topic.
This method will block until the operation is completed. Once the consumer is unsubscribed, no more messages will be received and subsequent new messages will not be retained for this consumer.
This consumer object cannot be reused.
callback | the callback to get notified when the operation is complete |