Skip to content

kafka send-receive-messages

Send messages to kafka topic and read with a comsumer

Description

Send Messages to topic and read them with a consumer.

Synopsis

kafka send-receive-messages
    [--site <site>]
    [--cluster <cluster>]
    --topic <topic>
    [--asynchronous]
    [--key <key>]
    [--messages <messages>]
    [--partitions <partitions>]
    [--offset_option <offset_option>]
    [--offset_value <offset_value>]

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

partitions - (int)

     partition number from which consumer should consume. Multiple partitions can be consumed
     Example: --partitions 1
     Default: _None_      Attributes: optional, multiple allowed

offset_option - (string)

     Value can be either "OLDEST" or "NEWEST"
     Example: --offset_option "OLDEST" , --offset_option "NEWEST"
     Default: _None_      Attributes: optional

     Validation:
         allowed values: OLDEST, NEWEST

offset_value - (int)

     offset from which messages are read in the provided partitions. Provide either offset_option or offset_value
     Example: --offset_value 1
     Default: _None_      Attributes: optional

Examples

Input:

! kafka send-receive-messages --asynchronous --topic "test-topic-1" --key "1" --messages "hi" --messages "hello" --partitions 1 --offset_option "OLDEST"
Output:
[
  {
    "topic_name":"test-topic-1",
    "partition":1,
    "messages":[
      {
        "key":"1",
        "value":"hi"
      }
    ],
    "time":{
        "seconds":1653550892,
        "nanos":468828435
      }
  }
]

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.