Skip to content

kafka send-messages

Send messages to kafka topic

Description

Send Messages to topic. Can be sent either synchronously or asynchronously

Synopsis

kafka send-messages
    [--site <site>]
    [--cluster <cluster>]
    --topic <topic>
    [--asynchronous]
    [--key <key>]
    [--messages <messages>]

Arguments

site - (string)

     Site where this command will be executed
     Example: --site "site-1"
     Default: input.site      Attributes: optional

cluster - (string)

     Name of kafka cluster
     Example: --cluster "cluster-1"
     Default: default      Attributes: optional

topic - (string)

     Name of kafka topic
     Example: --topic "topic-1"
     Default: _None_      Attributes: required

asynchronous - (bool)

     Send messages asynchronously
     Example: --asynchronous
     Default: _None_      Attributes: optional

key - (string)

     Message key
     Example: --key "key-1"
     Default: _None_      Attributes: optional

messages - (string)

     Message to be sent
     Example: --messages "messages-1"
     Default: _None_      Attributes: optional, multiple allowed

Examples

Input:

! kafka send-messages --asynchronous --topic "test-topic-1" --key "1" --messages "hi" --messages "hello"
Output:
[
  {
    "topic_name":"test-topic-1",
    "offset":3,
    "time":{
      "seconds":1653551998,
      "nanos":115288839
    }
  },
  {
    "topic_name":"test-topic-1",
    "offset":4,
    "time":{
      "seconds":1653551998,
      "nanos":115590761
    }
  }
]

Access Control

To use this command, you need access to the following:

Field Value
Action "update"
Service Type "kafka"
Service Instance cluster
Namespace
Object Type "topic"
Object ID topic

Please see Access Control for details.