pulsar-client-cpp
|
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 &subscriptionName, Consumer &consumer) |
Result | subscribe (const std::string &topic, const std::string &subscriptionName, const ConsumerConfiguration &conf, Consumer &consumer) |
void | subscribeAsync (const std::string &topic, const std::string &subscriptionName, SubscribeCallback callback) |
void | subscribeAsync (const std::string &topic, const std::string &subscriptionName, 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 ®exPattern, const std::string &subscriptionName, Consumer &consumer) |
Result | subscribeWithRegex (const std::string ®exPattern, const std::string &subscriptionName, const ConsumerConfiguration &conf, Consumer &consumer) |
void | subscribeWithRegexAsync (const std::string ®exPattern, const std::string &subscriptionName, SubscribeCallback callback) |
void | subscribeWithRegexAsync (const std::string ®exPattern, const std::string &subscriptionName, 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 | createTableView (const std::string &topic, const TableViewConfiguration &conf, TableView &tableView) |
void | createTableViewAsync (const std::string &topic, const TableViewConfiguration &conf, TableViewCallback 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 () |
uint64_t | getNumberOfProducers () |
Get the number of alive producers on the current client. | |
uint64_t | getNumberOfConsumers () |
Get the number of alive consumers on the current client. | |
void | getSchemaInfoAsync (const std::string &topic, int64_t version, std::function< void(Result, const SchemaInfo &)> callback) |
Friends | |
class | PulsarFriend |
class | PulsarWrapper |
pulsar::Client::Client | ( | const std::string & | serviceUrl | ) |
Create a Pulsar client object connecting to the specified cluster address and using the default configuration.
serviceUrl | the Pulsar endpoint to use (eg: pulsar://localhost:6650) |
std::invalid_argument | if serviceUrl is invalid |
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.
serviceUrl | the Pulsar endpoint to use (eg: http://brokerv2-pdev.messaging.corp.gq1.yahoo.com:4080 for Sandbox access) |
clientConfiguration | the client configuration to use |
std::invalid_argument | if serviceUrl is invalid |
Result pulsar::Client::close | ( | ) |
void pulsar::Client::closeAsync | ( | CloseCallback | callback | ) |
Asynchronously close the Pulsar client and release all resources.
All producers, consumers, and readers are orderly closed. The client waits until all pending write requests are persisted.
callback | the callback that is triggered when the Pulsar client is asynchronously closed successfully or not |
Result pulsar::Client::createProducer | ( | const std::string & | topic, |
const ProducerConfiguration & | conf, | ||
Producer & | producer | ||
) |
Create a producer with specified configuration
topic | the topic where the new producer will publish |
conf | the producer config to use |
producer | a non-const reference where the new producer will be copied |
Create a producer with default configuration
topic | the topic where the new producer will publish |
producer | a non-const reference where the new producer will be copied |
void pulsar::Client::createProducerAsync | ( | const std::string & | topic, |
CreateProducerCallback | callback | ||
) |
Asynchronously create a producer with the default ProducerConfiguration for publishing on a specific topic
topic | the name of the topic where to produce |
callback | the callback that is triggered when the producer is created successfully or not |
callback | Callback function that is invoked when the operation is completed |
void pulsar::Client::createProducerAsync | ( | const std::string & | topic, |
ProducerConfiguration | conf, | ||
CreateProducerCallback | callback | ||
) |
Asynchronously create a producer with the customized ProducerConfiguration for publishing on a specific topic
topic | the name of the topic where to produce |
conf | the customized ProducerConfiguration |
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. topic | The name of the topic where to read |
startMessageId | The message id where the reader will position itself. The first message returned will be the one after the specified startMessageId |
conf | The ReaderConfiguration object |
Reader
object void pulsar::Client::createReaderAsync | ( | const std::string & | topic, |
const MessageId & | startMessageId, | ||
const ReaderConfiguration & | conf, | ||
ReaderCallback | callback | ||
) |
Asynchronously create a topic reader with the customized 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. The reader can only work on non-partitioned topics.
The initial reader positioning is done by specifying a message ID. The options are as below:
MessageId.earliest
: start reading from the earliest message available in the topic MessageId.latest
: start reading from the latest topic, only getting messages published after the reader was created MessageId
: when passing a particular message ID, the reader positions itself on that is the message next to the specified messageId. topic | the name of the topic where to read |
startMessageId | the message ID where the reader positions itself. The first message returned is the one after the specified startMessageId |
conf | the ReaderConfiguration object |
Result pulsar::Client::createTableView | ( | const std::string & | topic, |
const TableViewConfiguration & | conf, | ||
TableView & | tableView | ||
) |
Create a table view with given TableViewConfiguration
for specified topic.
The TableView provides a key-value map view of a compacted topic. Messages without keys will be ignored.
topic | The name of the topic. |
conf | The TableViewConfiguration object |
tableView | The TableView object |
void pulsar::Client::createTableViewAsync | ( | const std::string & | topic, |
const TableViewConfiguration & | conf, | ||
TableViewCallback | callBack | ||
) |
Async create a table view with given TableViewConfiguration
for specified topic.
The TableView provides a key-value map view of a compacted topic. Messages without keys will be ignored.
topic | The name of the topic. |
conf | The TableViewConfiguration object |
callBack | The callback that is triggered when the TableView is successfully linked to the topic and the map is built from a message that already exists |
uint64_t pulsar::Client::getNumberOfConsumers | ( | ) |
Get the number of alive consumers on the current client.
uint64_t pulsar::Client::getNumberOfProducers | ( | ) |
Get the number of alive producers on the current client.
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.
topic | the topic name |
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.
topic | the topic name |
callback | the callback that will be invoked when the list of partitions is available |
void pulsar::Client::getSchemaInfoAsync | ( | const std::string & | topic, |
int64_t | version, | ||
std::function< void(Result, const SchemaInfo &)> | callback | ||
) |
Asynchronously get the SchemaInfo of a topic and a specific version.
@topic the topic name
void pulsar::Client::shutdown | ( | ) |
Perform immediate shutdown of Pulsar client.
Release all resources and close all producer, consumer, and readers without waiting for ongoing operations to complete.
Result pulsar::Client::subscribe | ( | const std::string & | topic, |
const std::string & | subscriptionName, | ||
const ConsumerConfiguration & | conf, | ||
Consumer & | consumer | ||
) |
Subscribe to a given topic and subscription combination with the customized ConsumerConfiguration
topic | the topic name | |
subscriptionName | the subscription name | |
[out] | consumer | the consumer instance to be returned |
Result pulsar::Client::subscribe | ( | const std::string & | topic, |
const std::string & | subscriptionName, | ||
Consumer & | consumer | ||
) |
Subscribe to a given topic and subscription combination with the default ConsumerConfiguration
topic | the topic name | |
subscriptionName | the subscription name | |
[out] | consumer | the consumer instance to be returned |
Result pulsar::Client::subscribe | ( | const std::vector< std::string > & | topics, |
const std::string & | subscriptionName, | ||
const ConsumerConfiguration & | conf, | ||
Consumer & | consumer | ||
) |
Subscribe to multiple topics with the customized ConsumerConfiguration under the same namespace
topics | a list of topic names to subscribe to | |
subscriptionName | the subscription name | |
conf | the customized ConsumerConfiguration | |
[out] | consumer | the consumer instance to be returned |
Result pulsar::Client::subscribe | ( | const std::vector< std::string > & | topics, |
const std::string & | subscriptionName, | ||
Consumer & | consumer | ||
) |
Subscribe to multiple topics under the same namespace.
topics | a list of topic names to subscribe to | |
subscriptionName | the subscription name | |
[out] | consumer | the consumer instance to be returned |
void pulsar::Client::subscribeAsync | ( | const std::string & | topic, |
const std::string & | subscriptionName, | ||
const ConsumerConfiguration & | conf, | ||
SubscribeCallback | callback | ||
) |
Asynchronously subscribe to a given topic and subscription combination with the customized ConsumerConfiguration
topic | the topic name |
subscriptionName | the subscription name |
conf | the customized ConsumerConfiguration |
callback | the callback that is triggered when a given topic and subscription combination with the customized ConsumerConfiguration are asynchronously subscribed successfully or not |
void pulsar::Client::subscribeAsync | ( | const std::string & | topic, |
const std::string & | subscriptionName, | ||
SubscribeCallback | callback | ||
) |
Asynchronously subscribe to a given topic and subscription combination with the default ConsumerConfiguration
topic | the topic name |
subscriptionName | the subscription name |
callback | the callback that is triggered when a given topic and subscription combination with the default ConsumerConfiguration are asynchronously subscribed successfully or not |
void pulsar::Client::subscribeAsync | ( | const std::vector< std::string > & | topics, |
const std::string & | subscriptionName, | ||
const ConsumerConfiguration & | conf, | ||
SubscribeCallback | callback | ||
) |
Asynchronously subscribe to a list of topics and subscription combination using the customized ConsumerConfiguration
topics | the topic list |
subscriptionName | the subscription name |
conf | the customized ConsumerConfiguration |
callback | the callback that is triggered when a list of topics and subscription combination using the customized ConsumerConfiguration are asynchronously subscribed successfully or not |
void pulsar::Client::subscribeAsync | ( | const std::vector< std::string > & | topics, |
const std::string & | subscriptionName, | ||
SubscribeCallback | callback | ||
) |
Asynchronously subscribe to a list of topics and subscription combination using the default ConsumerConfiguration
topics | the topic list |
subscriptionName | the subscription name |
callback | the callback that is triggered when a list of topics and subscription combination using the default ConsumerConfiguration are asynchronously subscribed successfully or not |
Result pulsar::Client::subscribeWithRegex | ( | const std::string & | regexPattern, |
const std::string & | subscriptionName, | ||
const ConsumerConfiguration & | conf, | ||
Consumer & | consumer | ||
) |
Subscribe to multiple topics (which match given regexPatterns) with the customized ConsumerConfiguration under the same namespace
Result pulsar::Client::subscribeWithRegex | ( | const std::string & | regexPattern, |
const std::string & | subscriptionName, | ||
Consumer & | consumer | ||
) |
Subscribe to multiple topics, which match given regexPattern, under the same namespace.
void pulsar::Client::subscribeWithRegexAsync | ( | const std::string & | regexPattern, |
const std::string & | subscriptionName, | ||
const ConsumerConfiguration & | conf, | ||
SubscribeCallback | callback | ||
) |
Asynchronously subscribe to multiple topics (which match given regexPatterns) with the customized ConsumerConfiguration under the same namespace
regexPattern | the regular expression for topics pattern |
subscriptionName | the subscription name |
conf | the ConsumerConfiguration |
callback | the callback that is triggered when multiple topics with the customized ConsumerConfiguration under the same namespace are asynchronously subscribed successfully or not |
void pulsar::Client::subscribeWithRegexAsync | ( | const std::string & | regexPattern, |
const std::string & | subscriptionName, | ||
SubscribeCallback | callback | ||
) |
Asynchronously subscribe to multiple topics (which match given regexPatterns) with the default ConsumerConfiguration under the same namespace