kafkatopic create

Creates a Kafka topic.

Syntax

IMPORTANT
Ensure that the mapr-kafka package is installed on the server node, before running the kafkatopic create command. When mapr-kafka package is not installed, the following error is encountered: Command execution failed! 'kafkatopic' commands requires 'mapr-kafka' package.
CLI

The maprcli command creates a Kafka topic.

$ maprcli kafkatopic create -topic <topicname> [-parameter <parameter value> -parameter <parameter value>..]
REST
http[s]://<host>:<port>/rest/kafkatopic/create?topic=<topicname>&parameter=<value>&parameter=<value>&parameter=<value>

Parameters

Parameter Description
-topic The topic name. This is a mandatory parameter.
-partitions The number of partitions. Default value is 1. This is an optional parameter.
-ttl The time to live in seconds. Default value is 604800. This is an optional parameter.
-ownvolume specifies if the topic is created in its own Data Fabric volume. Only users with Create Volumes (cv) or Full Control (fc) can specify “true” for this parameter. Default value is false. This is an optional parameter.
-compression Turn compression on or off with this parameter. lzf, lz4, zlib are the supported compression schemes. Default value is off. This is an optional parameter.

Examples

Use the command maprcli kafkatopic create -topic to create a topic by the name day_temperature.
$ maprcli kafkatopic create -topic day_temperature
TIP
Verify the topic creation with the maprcli kafkatopic info command.
$ maprcli kafkatopic info -topic day_temperature -json
{
        "timestamp":1681933868166,
        "timeofday":"2023-04-19 12:51:08.166 GMT-0700 PM",
        "status":"OK",
        "total":1,
        "data":[
                {
                        "topic":"day_temperature",
                        "owner":"root",
                        "partitions":1,
                        "ttl":604800,
                        "compression":"off",
                        "size":0,
                        "ownvolume":false
                }
        ]
}

Create a topic night_temp with time to live as 40000 seconds, 4 partitions and zlib compression scheme.

$ maprcli kafkatopic create -topic night_temp -ttl 40000 -partitions 4 -compression zlib