This document provides examples about how to use the Pulsar C++ client to connect to a Pulsar cluster through a token or an OAuth2 credential file.
This document assumes that you have created a service account, and have granted the service account produce
and consume
permissions to the namespace for the target topic.
This section describes how to connect to you Pulsar cluster using a token.
To connect to your Pulsar cluster using a token, follow these steps.
Connect to the Pulsar cluster.
Set the SERVICE_URL
and AUTH_PARAMS
parameters based on the descriptions in the prepare to connect to a Pulsar cluster user guide.
Create a C++ consumer and use the C++ consumer to consume messages.
Create a C++ producer and use the C++ producer to produce messages.
To connect to your Pulsar cluster using an OAuth2 credential file, follow these steps.
Generate the App credentials by following similar instructions in configure OAuth2 authentication.
Save the App credentials into an OAuth2 credential file.
Connect to your Pulsar cluster through the OAuth2 credential file.
issuerUrl
: the URL of your OAuth2 identity provider.private_key
: the path to your OAuth2 credential file.audience
: the audience
of your Pulsar cluster.client
: the URL of your Pulsar cluster.Create a C++ consumer and use the C++ consumer to consume messages.
Create a C++ producer and use the C++ producer to produce messages.
This document provides examples about how to use the Pulsar C++ client to connect to a Pulsar cluster through a token or an OAuth2 credential file.
This document assumes that you have created a service account, and have granted the service account produce
and consume
permissions to the namespace for the target topic.
This section describes how to connect to you Pulsar cluster using a token.
To connect to your Pulsar cluster using a token, follow these steps.
Connect to the Pulsar cluster.
Set the SERVICE_URL
and AUTH_PARAMS
parameters based on the descriptions in the prepare to connect to a Pulsar cluster user guide.
Create a C++ consumer and use the C++ consumer to consume messages.
Create a C++ producer and use the C++ producer to produce messages.
To connect to your Pulsar cluster using an OAuth2 credential file, follow these steps.
Generate the App credentials by following similar instructions in configure OAuth2 authentication.
Save the App credentials into an OAuth2 credential file.
Connect to your Pulsar cluster through the OAuth2 credential file.
issuerUrl
: the URL of your OAuth2 identity provider.private_key
: the path to your OAuth2 credential file.audience
: the audience
of your Pulsar cluster.client
: the URL of your Pulsar cluster.Create a C++ consumer and use the C++ consumer to consume messages.
Create a C++ producer and use the C++ producer to produce messages.