Use Pulsar Tools With StreamNative Cloud
Apache Pulsar provides a suite of command-line interface (CLI) tools that can be accessed from the bin/
directory after downloading and extracting the Pulsar distribution. These tools offer a range of capabilities, including starting and stopping Pulsar, managing tenants, namespace, & topics, and doing other operations such as benchmarking. To learn how to use each tool, simply run it with no argument or use the --help
argument for detailed instructions.
Most of the Pulsar client CLI tools use a configuration file client.conf
stored in the conf/
directory to connect to a Pulsar cluster. You can edit this file to specify the required information to connect to your StreamNative Cloud cluster.
Collect your cluster information
You need to gather the following information for your StreamNative Cloud cluster:
- webServiceUrl: The Pulsar Web Service URL used for accessing the Pulsar admin interface
- brokerServiceUrl: The Pulsar Broker Service URL used for connecting to the Pulsar brokers
- API Key: The API Key for your StreamNative Cloud account
-
Sign in to your StreamNative Cloud account.
-
In the Cloud Console, navigate to the cluster you want to connect to.
-
In the Cluster Dashboard page, select the Details tab.
-
Copy the HTTP Service URL (TLS) value and paste it into the
webServiceUrl
property in theclient.conf
file. -
Copy the Broker Service URL (TLS) value and paste it into the
brokerServiceUrl
property in theclient.conf
file. -
Follow the instructions in Create an API key to create an API key and copy the API Key value.
-
Add the following value
token:<api-key>
to theauthParams
property in theclient.conf
file.<api-key>
is the value you copied in the previous step. -
Update the
authPlugin
property in theclient.conf
file toorg.apache.pulsar.client.impl.auth.AuthenticationToken
.
Use the tools
Run admin commands
You can use the pulsar-admin
tool to run admin operations on your StreamNative Cloud cluster. For example, you can use the following command to list all the available tenants in your cluster:
Please make sure the service account has the necessary permissions to run the command.
Produce messages
You can use the pulsar-client
tool to produce messages to a Pulsar topic. For example, you can use the following command to produce 10 messages to a topic named my-topic
:
You should see the following output at the end of the command:
Consume messages
You can use the pulsar-client
tool to consume messages from a Pulsar topic. For example, you can use the following command to consume 10 messages from a topic named my-topic
:
You should see a similar output to the following: