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

Public Member Functions

 Client (const std::string &serviceUrl)
 
 Client (const std::string &serviceUrl, const ClientConfiguration &clientConfiguration)
 
Result createProducer (const std::string &topic, Producer &producer)
 
Result createProducer (const std::string &topic, const ProducerConfiguration &conf, Producer &producer)
 
void createProducerAsync (const std::string &topic, CreateProducerCallback callback)
 
void createProducerAsync (const std::string &topic, ProducerConfiguration conf, CreateProducerCallback callback)
 
Result subscribe (const std::string &topic, const std::string &consumerName, Consumer &consumer)
 
Result subscribe (const std::string &topic, const std::string &consumerName, const ConsumerConfiguration &conf, Consumer &consumer)
 
void subscribeAsync (const std::string &topic, const std::string &consumerName, SubscribeCallback callback)
 
void subscribeAsync (const std::string &topic, const std::string &consumerName, const ConsumerConfiguration &conf, SubscribeCallback callback)
 
Result subscribe (const std::vector< std::string > &topics, const std::string &subscriptionName, Consumer &consumer)
 
Result subscribe (const std::vector< std::string > &topics, const std::string &subscriptionName, const ConsumerConfiguration &conf, Consumer &consumer)
 
void subscribeAsync (const std::vector< std::string > &topics, const std::string &subscriptionName, SubscribeCallback callback)
 
void subscribeAsync (const std::vector< std::string > &topics, const std::string &subscriptionName, const ConsumerConfiguration &conf, SubscribeCallback callback)
 
Result subscribeWithRegex (const std::string &regexPattern, const std::string &consumerName, Consumer &consumer)
 
Result subscribeWithRegex (const std::string &regexPattern, const std::string &consumerName, const ConsumerConfiguration &conf, Consumer &consumer)
 
void subscribeWithRegexAsync (const std::string &regexPattern, const std::string &consumerName, SubscribeCallback callback)
 
void subscribeWithRegexAsync (const std::string &regexPattern, const std::string &consumerName, const ConsumerConfiguration &conf, SubscribeCallback callback)
 
Result createReader (const std::string &topic, const MessageId &startMessageId, const ReaderConfiguration &conf, Reader &reader)
 
void createReaderAsync (const std::string &topic, const MessageId &startMessageId, const ReaderConfiguration &conf, ReaderCallback callback)
 
Result getPartitionsForTopic (const std::string &topic, std::vector< std::string > &partitions)
 
void getPartitionsForTopicAsync (const std::string &topic, GetPartitionsCallback callback)
 
Result close ()
 
void closeAsync (CloseCallback callback)
 
void shutdown ()
 

Friends

class PulsarFriend
 
class PulsarWrapper
 

Constructor & Destructor Documentation

◆ Client() [1/2]

pulsar::Client::Client ( const std::string &  serviceUrl)

Create a Pulsar client object connecting to the specified cluster address and using the default configuration.

Parameters
serviceUrlthe Pulsar endpoint to use (eg: pulsar://localhost:6650)

◆ Client() [2/2]

pulsar::Client::Client ( const std::string &  serviceUrl,
const ClientConfiguration &  clientConfiguration 
)

Create a Pulsar client object connecting to the specified cluster address and using the specified configuration.

Parameters
serviceUrlthe Pulsar endpoint to use (eg: http://brokerv2-pdev.messaging.corp.gq1.yahoo.com:4080 for Sandbox access)
clientConfigurationthe client configuration to use

Member Function Documentation

◆ close()

Result pulsar::Client::close ( )
Returns

◆ createProducer() [1/2]

Result pulsar::Client::createProducer ( const std::string &  topic,
const ProducerConfiguration &  conf,
Producer &  producer 
)

Create a producer with specified configuration

See also
createProducer(const std::string&, const ProducerConfiguration&, Producer&)
Parameters
topicthe topic where the new producer will publish
confthe producer config to use
producera non-const reference where the new producer will be copied
Returns
ResultOk if the producer has been successfully created
ResultError if there was an error

◆ createProducer() [2/2]

Result pulsar::Client::createProducer ( const std::string &  topic,
Producer &  producer 
)

Create a producer with default configuration

See also
createProducer(const std::string&, const ProducerConfiguration&, Producer&)
Parameters
topicthe topic where the new producer will publish
producera non-const reference where the new producer will be copied
Returns
ResultOk if the producer has been successfully created
ResultError if there was an error

◆ createReader()

Result pulsar::Client::createReader ( const std::string &  topic,
const MessageId &  startMessageId,
const ReaderConfiguration &  conf,
Reader &  reader 
)

Create a topic reader with given

ReaderConfiguration

for reading messages from the specified topic.

The Reader provides a low-level abstraction that allows for manual positioning in the topic, without using a subscription. Reader can only work on non-partitioned topics.

The initial reader positioning is done by specifying a message id. The options are:

  • MessageId.earliest : Start reading from the earliest message available in the topic
  • MessageId.latest : Start reading from the end topic, only getting messages published after the reader was created
  • MessageId : When passing a particular message id, the reader will position itself on that specific position. The first message to be read will be the message next to the specified messageId.
Parameters
topicThe name of the topic where to read
startMessageIdThe message id where the reader will position itself. The first message returned will be the one after the specified startMessageId
confThe
ReaderConfiguration
object
Returns
The
Reader
object

◆ getPartitionsForTopic()

Result pulsar::Client::getPartitionsForTopic ( const std::string &  topic,
std::vector< std::string > &  partitions 
)

Get the list of partitions for a given topic.

If the topic is partitioned, this will return a list of partition names. If the topic is not partitioned, the returned list will contain the topic name itself.

This can be used to discover the partitions and create Reader, Consumer or Producer instances directly on a particular partition.

Parameters
topicthe topic name
Since
2.3.0

◆ getPartitionsForTopicAsync()

void pulsar::Client::getPartitionsForTopicAsync ( const std::string &  topic,
GetPartitionsCallback  callback 
)

Get the list of partitions for a given topic in asynchronous mode.

If the topic is partitioned, this will return a list of partition names. If the topic is not partitioned, the returned list will contain the topic name itself.

This can be used to discover the partitions and create Reader, Consumer or Producer instances directly on a particular partition.

Parameters
topicthe topic name
callbackthe callback that will be invoked when the list of partitions is available
Since
2.3.0

◆ subscribe()

Result pulsar::Client::subscribe ( const std::vector< std::string > &  topics,
const std::string &  subscriptionName,
Consumer &  consumer 
)

subscribe for multiple topics under the same namespace.

◆ subscribeWithRegex()

Result pulsar::Client::subscribeWithRegex ( const std::string &  regexPattern,
const std::string &  consumerName,
Consumer &  consumer 
)

subscribe for multiple topics, which match given regexPattern, under the same namespace.


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