pulsar-admin topics: Create and Inspect Topics
pulsar-admin topics create persistent://<tenant>/<namespace>/<topic> creates a Pulsar topic through the admin REST API, useful for provisioning before tests.
Pulsar topics are named persistent://tenant/namespace/topic. pulsar-admin drives the broker admin API to create, list, and get stats on them from a CI setup step.
What it does
pulsar-admin topics manages topics via the broker admin endpoint (default http://localhost:8080). create makes a topic (add -p N for a partitioned topic), list shows topics in a namespace, and stats reports subscriptions and backlog. Topic names are fully qualified with the persistent:// scheme.
Common usage
# create a non-partitioned topic
pulsar-admin topics create persistent://public/default/orders
# create a partitioned topic with 3 partitions
pulsar-admin topics create-partitioned-topic \
persistent://public/default/orders -p 3
pulsar-admin topics list public/default
pulsar-admin topics stats persistent://public/default/ordersOptions
| Command / flag | What it does |
|---|---|
| topics create <fqtn> | Create a non-partitioned topic |
| topics create-partitioned-topic <fqtn> -p <n> | Create a partitioned topic |
| topics list <tenant>/<ns> | List topics in a namespace |
| topics stats <fqtn> | Show subscriptions, backlog, and rates |
| --admin-url <url> | Override the admin service URL |
In CI
Use the fully-qualified persistent://public/default/... form; the default tenant and namespace are public/default in a standalone broker. Set the admin URL via --admin-url or the PULSAR_ADMIN_CONF client config if the broker is not on localhost:8080.
Common errors in CI
"Namespace does not exist" means the tenant/namespace is missing; create it with pulsar-admin namespaces create first. "Connection refused" to :8080 means the broker admin API is not up yet; wait for standalone startup, which takes several seconds. "HTTP 409 Conflict" on create means the topic already exists.