Topics in Pulsar are used as a channel through which messages are produced and consumed. There are two main types of topics:
Before you run the commands below, make sure you have started Pulsar.
To create a new non-partitioned topic in Pulsar, we need to provide the mandatory parameters:
./bin/pulsar-admin topics create persistent://my-tenant/my-namespace/my-topic
To create a new partitioned topic in Pulsar, we need to provide the mandatory parameters:
./bin/pulsar-admin topics create-partitioned-topic persistent://my-tenant/my-namespace/my-partitioned-topic --partitions 5
To list all topics under a namespace in Pulsar, we need to provide the mandatory parameters:
./bin/pulsar-admin topics list my-tenant/my-namespace
To list only the partitioned topics under a namespace in Pulsar, we need to provide the mandatory parameters:
./bin/pulsar-admin topics list-partitioned-topics my-tenant/my-namespace
To get statistics information about a topic in Pulsar, we need to provide the mandatory parameters:
# For non-partitioned topics
./bin/pulsar-admin topics stats persistent://my-tenant/my-namespace/my-topic
# For partitioned topics
./bin/pulsar-admin topics partitioned-stats persistent://my-tenant/my-namespace/my-partitioned-topic
To delete a topic in Pulsar, we need to provide the mandatory parameters:
# For non-partitioned topics
./bin/pulsar-admin topics delete persistent://my-tenant/my-namespace/my-topic
# For partitioned topics
./bin/pulsar-admin topics delete-partitioned-topic persistent://my-tenant/my-namespace/my-partitioned-topic