topic create

Prev Next

This command creates a topic for event publishing.

Usage

topic create --database-name NAME
             --name NAME
             --topic-partitions COUNT
             [--retention-ms MILLISECONDS] 
             [--message-timestamp-type CreateTime|LogAppendTime] 
             [--message-timestamp-before-max-ms MILLISECONDS]
             [--message-timestamp-after-max-ms MILLISECONDS]

Required Parameters

--database-name NAME

The name of the database where the topic is to be created.

--name NAME

The name of the topic to be created.

--topic-partitions

The number of partitions in the topic to be created.

Each partition can hold up to 1000 topics. The number of partitions in a topic cannot be changed after the topic has been created.

Options

--retention-ms MILLISECONDS

The amount of time, in milliseconds, to keep an event record in the topic. When the retention period for a record expires, the records is deleted from the topic.

The default retention period is seven days. The minimum allowed retention period is 6 hours. A value of -1 means no retention period.

--message-timestamp-type CreateTime|LogAppendTime

Determines how the event timestamp is set:

  • CreateTime (default): The timestamp is based on the time when the event was encountered at the event producer.

  • LogAppendTime: The timestamp is based on the time when the event record was added to the log at the event broker.

--message-timestamp-before-max-ms MILLISECONDS

If the message timestamp type is set to CreateTime, specify this option to determine how much earlier the message timestamp can be than the broker timestamp. If this value is exceeded, the message is rejected.

--message-timestamp-after-max-ms MILLISECONDS

If the message timestamp type is set to CreateTime, specify this option to determine how much later the message timestamp can be than the broker timestamp. If this value is exceeded, the message is rejected.

Example

To create a topic named mytopic with 30 partitions in the kafkatopics database:

vcli: admin> topic create --database-name kafkatopics --name mytopic --partitions 30