Skip to main content

KAFKA::PRODUCER

Publishes messages to a Kafka topic.

Syntax

actions:
<action-id>:
type: KAFKA::PRODUCER
props:
topic: <topic_name>
value: <message_value>

Properties

PropertyDescriptionType
<action-id>Unique identifier for the actionstring
typeType of the actionstring
propsProperties specific to this action. Refer to props section for more details.object

props

PropertyDescriptionTypeRequired
topicThe Kafka topic to which the message is to be published.stringtrue
keyKey of the message to be publishedstring
valueValue of the message to be publishedstring, long, float, or objecttrue
partitionPartition to which the message is being writtennumber

Example

kafkaProducerTest.yml
actions:
publish:
type: KAFKA::PRODUCER
props:
topic: example_topic
value: "Hello, World!"

tests:
kafkaProducerTest:
tasks:
- resource: resources.kafka
action: actions.publish

Output

📝 Note: Can be accessed using context["last_output"]

KeyDescriptionType
topicTopic name of the messagestring
partitionPartition number where the message was publishedlong
offsetOffset of the message within the partitionlong
timestampTimestamp of the message in millisecondslong
timeTakenTime taken, in millisecondslong
errorError message, if any, produced while publishing the messagestring

Example

{
"timeTaken": 155,
"rows": [
{
"id": 1,
"name": "PostgreSQL Tutorial",
"url": "https://www.postgresqltutorial.com"
}
]
}