1. StreamNative Platform
  2. 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.

  1. On the left navigation pane, under RESOURCES, click Topics.

  2. Click New Topic.

  3. Configure the topic, as outlined in the following table.

    ItemDescription
    DomainConfigure 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 NameEnter 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.
  4. Click Confirm.

  5. (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.

  1. On the left navigation pane, under RESOURCES, click Topics.

  2. Click the topic name link to display detailed information about that topic.

  3. If the topic is partitioned, click the partition link of the selected topic.

  4. 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.

    ItemDescription
    Info
    In RateThe ingress rate of the topic.
    Out RateThe egress rate of the topic.
    In ThroughputThe ingress throughput of the topic.
    Out ThroughputThe egress throughput of the topic.
    Producers
    Producer IDThe producer ID of the topic.
    Producer NameThe producer name of the topic.
    In RateThe ingress rate of the topic.
    In ThroughputThe ingress throughput of the topic.
    Avg Msg SizeThe average message size of the topic.
    AddressThe address of the topic.
    SinceWhen the producer is created.
    Subscriptions
    Subscription NameThe subscription name of the topic.
    TypeThe 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 RateThe egress rate of the topic.
    Out ThroughputThe egress throughput of the topic.
    Msg ExpiredThe expired messages for the topic.
    BacklogConfigure 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.

  1. On the left navigation pane, under RESOURCES, click Topics.

  2. Click the topic name link to display detailed information about that topic.

  3. If the topic is partitioned, click the partition link of the selected topic.

  4. Select the SCHEMA tab and then click Create schema. The Create a Pulsar schema page displays.

  5. Select a schema type from the Schema Type drop-down list.

  6. Configure the key and the value and then click Confirm.

Peek messages for a topic

To peek messages for a topic, follow these steps.

  1. On the left navigation pane, under RESOURCES, click Topics.

  2. Click the topic name link to display detailed information about that topic.

  3. If the topic is partitioned, click the partition link of the selected topic.

  4. Select the MESSAGES tab.

  5. 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.

  6. Click Confirm.

Check storage

To check storage for a topic, follow these steps.

  1. On the left navigation pane, under RESOURCES, click Topics.

  2. Click the topic name link to display detailed information about that topic.

  3. If the topic is partitioned, click the partition link of the selected topic.

  4. Select the STORAGE tab and check storage information for this topic.

    ItemDescription
    Storage sizeThe storage size.
    EntriesThe entries.
    SegmentsThe segments.
    Ledgers
    Ledger IDThe ledger ID.
    EntriesThe total number of entries that belong to the ledger.
    SizeThe size of messages written to the ledger (in bytes).
    StatusThe state of the ledger for writing messages. If it is set to Opening, the ledger is open for saving published messages.
    OffloadWhether the ledger can be offloaded or not.
    Cursors
    CursorThe cursor ID.
    Mark Delete PositionAll messages before the markDeletePosition are acknowledged by the subscriber.
    Read PositionThe latest position for the subscriber to read messages.
    Waiting Read OpIt 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 OpThe number of read requests to the BookKeepers in progress.
    Entries Since First Not AckedMessageEntries that are not acknowledged.

Configure policies for a topic

To configure policies for a topics, follow these steps.

  1. On the left navigation pane, under RESOURCES, click Topics.

  2. Click the topic name link to display detailed information about that topic.

  3. If the topic is partitioned, click the partition link of the selected topic.

  4. Select the POLICIES tab and configure authorization policies for the topic.

    ItemDescription
    AuthorizationGrant/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.
  5. (Optional) Click Add Role to add more Admin roles for the topic.

Delete a topic

To delete a topic, follow these steps.

  1. On the left navigation pane, under RESOURCES, click Topics.

  2. Click the topic name link to display detailed information about that topic.

  3. If the topic is partitioned, click the partition link of the selected topic.

  4. Select the POLICIES tab and then click Delete Topic. A dialog box displays asking, Are you sure you want to delete this topic?

  5. Enter the topic name and then click Confirm.

Previous
Work with namespaces