Managing Namespaces
This page only shows some frequently used operations.
-
For the latest and complete information about
Pulsar admin, including commands, flags, descriptions, and more information, see Pulsar admin docs. -
For the latest and complete information about
REST API, including parameters, responses, samples, and more, see REST API doc. -
For the latest and complete information about
Java admin API, including classes, methods, descriptions, and more, see Java admin API doc.
Pulsar namespaces are logical groupings of topics.
Namespaces can be managed via:
- The
namespacescommand of thepulsar-admintool - The
/admin/v2/namespacesendpoint of the admin REST API - The
namespacesmethod of thePulsarAdminobject in the Java API
Namespaces resources
Create namespaces
You can create new namespaces under a given tenant.
- pulsar-admin
- REST API
- Java
Use the create subcommand and specify the namespace by name:
pulsar-admin namespaces create test-tenant/test-namespace
admin.namespaces().createNamespace(namespace);
Get policies
You can fetch the current policies associated with a namespace at any time.
- pulsar-admin
- REST API
- Java
Use the policies subcommand and specify the namespace:
pulsar-admin namespaces policies test-tenant/test-namespace
Example output:
{
"auth_policies": {
"namespace_auth": {},
"destination_auth": {}
},
"replication_clusters": [],
"bundles_activated": true,
"bundles": {
"boundaries": [
"0x00000000",
"0xffffffff"
],
"numBundles": 1
},
"backlog_quota_map": {},
"persistence": null,
"latency_stats_sample_rate": {},
"message_ttl_in_seconds": 0,
"retention_policies": null,
"deleted": false
}
admin.namespaces().getPolicies(namespace);
List namespaces
You can list all namespaces within a given Pulsar tenant.
- pulsar-admin
- REST API
- Java
Use the list subcommand and specify the tenant:
pulsar-admin namespaces list test-tenant
Example output:
test-tenant/namespace1
test-tenant/namespace2
admin.namespaces().getNamespaces(tenant);
Delete namespaces
You can delete existing namespaces from a tenant.
- pulsar-admin
- REST API
- Java
Use the delete subcommand and specify the namespace:
pulsar-admin namespaces delete test-tenant/namespace1
admin.namespaces().deleteNamespace(namespace);
Configure replication clusters
Set replication cluster
You can set replication clusters for a namespace to enable Pulsar to internally replicate the published messages from one colocation facility to another.
- pulsar-admin
- REST API
- Java
pulsar-admin namespaces set-clusters test-tenant/namespace1 --clusters cl1
admin.namespaces().setNamespaceReplicationClusters(namespace, clusters);
Get replication cluster
You can get the list of replication clusters for a given namespace.
- pulsar-admin
- REST API
- Java
pulsar-admin namespaces get-clusters test-tenant/cluster1/namespace1
Example output:
cluster2
admin.namespaces().getNamespaceReplicationClusters(namespace)
Configure backlog quota policies
Set backlog quota policies
Backlog quota helps the broker to restrict bandwidth/storage of a namespace once it reaches a certain threshold limit. Admin can set the limit and take the corresponding action after the limit is reached.
-
producer_request_hold: the producer holds the message and retries until client configuration
sendTimeoutMsis exceeded -
producer_exception: the producer throws an exception when trying to send a message
-
consumer_backlog_eviction: broker starts discarding backlog messages
Backlog quota restriction can be taken care of by defining the restriction of backlog-quota-type: destination_storage.
- pulsar-admin
- REST API
- Java
pulsar-admin namespaces set-backlog-quota --limit 10G \
--limitTime 36000 \
--policy producer_request_hold \
test-tenant/namespace1
admin.namespaces().setBacklogQuota(namespace, new BacklogQuota(limit, limitTime, policy))
Get backlog quota policies
You can get a configured backlog quota for a given namespace.
- pulsar-admin
- REST API
- Java
pulsar-admin namespaces get-backlog-quotas test-tenant/namespace1
Example output:
destination_storage BacklogQuotaImpl(limit=10737418240, limitSize=10737418240, limitTime=36000, policy=producer_request_hold)
admin.namespaces().getBacklogQuotaMap(namespace);
Remove backlog quota policies
You can remove backlog quota policies for a given namespace.
- pulsar-admin
- REST API
- Java
pulsar-admin namespaces remove-backlog-quota test-tenant/namespace1
admin.namespaces().removeBacklogQuota(namespace, backlogQuotaType)