- StreamNative Platform
- Administer
Work with topics
A topic is a named channel used to deliver messages published by producers to consumers. After creating a namespace, you can create one or more topics for the namespace.
This document describes how to create and manage topics for a cluster using the pulsarctl CLI tool or the StreamNative Console.
Work with topics using the pulsarctl CLI tool
This section describes how to create and manage topics using the pulsarctl CLI tool. For a full list of supported operations on topics, see pulsarctl command reference.
Before using the pulsarctl CLI tool to create and manage topics, you need to create a tenant and a namespace.
Create a topic
You can use the pulsarctl topics create TOPIC_NAME
command to create a topic.
If you want to create a non-partitioned topic, you need to set the number of partitions to
0
.This example shows how to create a non-partitioned topic in the
example-tenant/example-ns
namespace.Input
pulsarctl topics create example-tenant/example-ns/topic-test 0
Output
Create topic persistent://example-tenant/example-ns/topic-test with 0 partitions successfully
If you want to create a partitioned topic, you need to set the number of partitions to a specific number.
This example shows how to create a topic with 5 partitions in the
example-tenant/example-ns
namespace.Input
pulsarctl topics create example-tenant/example-ns/test-topic 5
Output
Create topic persistent://example-tenant/example-ns/test-topic with 5 partitions successfully
Manage a topic
This section describes how to manage topics using the pulsarctl CLI tool.
Get topic status
You can use the pulsarctl topics get TOPIC_NAME
command to get information about a specific topic.
This example shows how to list all topics available for the
example-tenant/example-ns
namespace.Input
pulsarctl topics list example-tenant/example-ns/
Output
+--------------------------------------------------------------------------------+-----------------------+ | TOPIC NAME | PARTITIONED ? | +--------------------------------------------------------------------------------+-----------------------+ | persistent://example-tenant/example-ns/topic-test | N | | persistent://example-tenant/example-ns/test-topic | Y | | persistent://example-tenant/example-ns/test-topic-partition-0 | N | | persistent://example-tenant/example-ns/test-topic-partition-1 | N | | persistent://example-tenant/example-ns/test-topic-partition-2 | N | | persistent://example-tenant/example-ns/test-topic-partition-3 | N | | persistent://example-tenant/example-ns/test-topic-partition-4 | N | +--------------------------------------------------------------------------------+-----------------------+
This example shows how to get detailed information about the
topic-test
topic.Input
pulsarctl topics get topic-test
Output
{ "partitions": 0 }
Delete a topic
You can use the pulsarctl topics delete TOPIC_NAME
command to delete a partitioned topic. To delete a non-partitioned topic, you need to set the --non-partitioned
parameter.
This example shows how to delete the
test-topic
partitioned topic.Input
pulsarctl topics delete topic-test
Output
Delete topic persistent://example-tenant/example-ns/test-topic successfully
This example shows how to delete the
topic-test
non-partitioned topic.Input
pulsarctl topics delete --non-partitioned topic-test
Output
Delete topic persistent://example-tenant/example-ns/topic-test successfully
Work with topics using StreamNative Console
This section describes how to work with topics using the StreamNative Console.
Create a topic
To create a topic, follow these steps.
To create a topic, follow these steps.
On the left navigation pane, under RESOURCES, click Topics.
Click New Topic.
Configure the topic, as outlined in the following table.
Item Description Domain Configure the type of the topic.
- Persistent: messages in a persistent topic are durably persisted on the storage disk.
- Non-persistent: messages in a non-persistent topic are not persisted on the storage disk.
By default, it is set to Persistent.Topic Name Enter a name for the topic. It is a string of up to 40 characters, supporting lowercase letters (a-z), numeric characters (0-9), and the special character hyphen (-). Partitions (Optional) configure the number of partitions for a partitioned topic. If this value is set to 0, it means this is a non-partitioned topic. Up to 16 partitions are available for a partitioned topic. Click Confirm.
(Optional) Click New Topic to add more topics for the namespace.
Manage a topic
This section describes how to manage topics using the StreamNative Console.
Perform basic operations for a topic
You can check detailed information about the target topic, unload, and compact topics, as well as configure the subscription name of the topics.
To perform basic operations for a topic, follow these steps.
On the left navigation pane, under RESOURCES, click Topics.
Click the topic name link to display detailed information about that topic.
If the topic is partitioned, click the partition link of the selected topic.
Select the OVERVIEW tab.
On the OVERVIEW tab, you can perform the following operations.
- Unload the topic: click Unload to unload the topic.
- Compact the topic: click Compact to compact the topic.
- Configure the subscription name of the topic: click New Subscription and a dialog box displays. Enter a name for the subscription and then click Confirm. Thereafter, the StreamNative Console can manage topics based on the subscription name.
- Check detailed information about the topic.
The following table outlines detailed information about the topic.
Item Description Info In Rate The ingress rate of the topic. Out Rate The egress rate of the topic. In Throughput The ingress throughput of the topic. Out Throughput The egress throughput of the topic. Producers Producer ID The producer ID of the topic. Producer Name The producer name of the topic. In Rate The ingress rate of the topic. In Throughput The ingress throughput of the topic. Avg Msg Size The average message size of the topic. Address The address of the topic. Since When the producer is created. Subscriptions Subscription Name The subscription name of the topic. Type The subscription type of the topic. Currently, the StreamNative Console does not support configuring the subscription type for a topic. You can configure the subscription type through Pulsar manager. Out Rate The egress rate of the topic. Out Throughput The egress throughput of the topic. Msg Expired The expired messages for the topic. Backlog Configure the backlog for the subscription.
- SKIP: skip some messages for the subscription.
- EXPIRE: expire messages that are older than the given expiry time (in seconds) for the subscription.
- CLEAR: clear the backlog for the subscription.
- RESET BY ID: reset the ID of the message at which the subscription is created.
- RESET BY TIME: reset the time when the subscription is created.
- PEEK: peek some messages for the subscription.
- UNSUBSCRIBE: delete the subscription.
Create schema for a topic
Currently, only Avro and JSON schema are supported on StreamNative Console.
To configure schema for a topic, follow these steps.
On the left navigation pane, under RESOURCES, click Topics.
Click the topic name link to display detailed information about that topic.
If the topic is partitioned, click the partition link of the selected topic.
Select the SCHEMA tab and then click Create schema. The Create a Pulsar schema page displays.
Select a schema type from the Schema Type drop-down list.
Configure the key and the value and then click Confirm.
Peek messages for a topic
To peek messages for a topic, follow these steps.
On the left navigation pane, under RESOURCES, click Topics.
Click the topic name link to display detailed information about that topic.
If the topic is partitioned, click the partition link of the selected topic.
Select the MESSAGES tab.
Select the subscription name from the Subscriptions drop-down list and set the number of messages that are going to be peeked for the subscription.
Click Confirm.
Check storage
To check storage for a topic, follow these steps.
On the left navigation pane, under RESOURCES, click Topics.
Click the topic name link to display detailed information about that topic.
If the topic is partitioned, click the partition link of the selected topic.
Select the STORAGE tab and check storage information for this topic.
Item Description Storage size The storage size. Entries The entries. Segments The segments. Ledgers Ledger ID The ledger ID. Entries The total number of entries that belong to the ledger. Size The size of messages written to the ledger (in bytes). Status The state of the ledger for writing messages. If it is set to Opening
, the ledger is open for saving published messages.Offload Whether the ledger can be offloaded or not. Cursors Cursor The cursor ID. Mark Delete Position All messages before the markDeletePosition
are acknowledged by the subscriber.Read Position The latest position for the subscriber to read messages. Waiting Read Op It is set to True
when the subscription has read the latest message published to the topic and is waiting for new messages to be published.Pending Read Op The number of read requests to the BookKeepers in progress. Entries Since First Not AckedMessage Entries that are not acknowledged.
Configure policies for a topic
To configure policies for a topics, follow these steps.
On the left navigation pane, under RESOURCES, click Topics.
Click the topic name link to display detailed information about that topic.
If the topic is partitioned, click the partition link of the selected topic.
Select the POLICIES tab and configure authorization policies for the topic.
Item Description Authorization Grant/Revoke permissions to other client roles.
- consume: grant/revoke the consuming action.
- produce: grant/revoke the producing action.
- functions: grant/revoke the Pulsar functions action.(Optional) Click Add Role to add more Admin roles for the topic.
Delete a topic
To delete a topic, follow these steps.
On the left navigation pane, under RESOURCES, click Topics.
Click the topic name link to display detailed information about that topic.
If the topic is partitioned, click the partition link of the selected topic.
Select the POLICIES tab and then click Delete Topic. A dialog box displays asking, Are you sure you want to delete this topic?
Enter the topic name and then click Confirm.