> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streamnative.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Use Pulsar Tools With StreamNative Cloud

Apache Pulsar provides a suite of [command-line interface (CLI) tools](https://pulsar.apache.org/docs/reference-cli-tools/) that can be accessed from the `bin/` directory after [downloading](https://pulsar.apache.org/download/) 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

1. Sign in to your StreamNative Cloud account.

2. In the Cloud Console, navigate to the cluster you want to connect to.

3. In the **Cluster Dashboard** page, select the **Details** tab.

4. Copy the **HTTP Service URL (TLS)** value and paste it into the `webServiceUrl` property in the `client.conf` file.

5. Copy the **Broker Service URL (TLS)** value and paste it into the `brokerServiceUrl` property in the `client.conf` file.

6. Follow the instructions in [Create an API key](/cloud/security/authentication/service-accounts/use-api-keys/api-keys-overview#create-an-api-key) to create an API key and copy the **API Key** value.

7. Add the following value `token:<api-key>` to the `authParams` property in the `client.conf` file. `<api-key>` is the value you copied in the previous step.

8. Update the `authPlugin` property in the `client.conf` file to `org.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:

<Warning title="Warning">
  Please make sure the service account has the necessary permissions to run the command.
</Warning>

```bash theme={null}
./bin/pulsar-admin tenants list
```

### 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`:

```bash theme={null}
bin/pulsar-client produce -m "test" -n 10 my_topic
```

You should see the following output at the end of the command:

```bash theme={null}
10 messages successfully produced
```

### 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`:

```bash theme={null}
bin/pulsar-client consume -n 10 -p Earliest -s my_sub my_topic
```

You should see a similar output to the following:

```bash theme={null}
----- got message -----
publishTime:[1732941461552], eventTime:[0], key:[null], properties:[], content:test
sidebarTitle: Use Pulsar Tools
----- got message -----
publishTime:[1732941461636], eventTime:[0], key:[null], properties:[], content:test
----- got message -----
publishTime:[1732941461704], eventTime:[0], key:[null], properties:[], content:test
sidebarTitle: Use Pulsar Tools
----- got message -----
publishTime:[1732941461774], eventTime:[0], key:[null], properties:[], content:test
----- got message -----
publishTime:[1732941461843], eventTime:[0], key:[null], properties:[], content:test
sidebarTitle: Use Pulsar Tools
----- got message -----
publishTime:[1732941461913], eventTime:[0], key:[null], properties:[], content:test
----- got message -----
publishTime:[1732941461982], eventTime:[0], key:[null], properties:[], content:test
sidebarTitle: Use Pulsar Tools
----- got message -----
publishTime:[1732941462051], eventTime:[0], key:[null], properties:[], content:test
----- got message -----
publishTime:[1732941462121], eventTime:[0], key:[null], properties:[], content:test
sidebarTitle: Use Pulsar Tools
----- got message -----
publishTime:[1732941462189], eventTime:[0], key:[null], properties:[], content:test
```
