KAFKA::PRODUCER
Publishes messages to a Kafka topic.
Prerequisite
Syntax
actions:
<action-id>:
type: KAFKA::PRODUCER
props:
topic: <topic_name>
value: <message_value>
Properties
Property | Description | Type |
---|---|---|
<action-id> | Unique identifier for the action | string |
type | Type of the action | string |
props | Properties specific to this action. Refer to props section for more details. | object |
props
Property | Description | Type | Required |
---|---|---|---|
topic | The Kafka topic to which the message is to be published. | string | true |
key | Key of the message to be published | string | |
value | Value of the message to be published | string , long , float , or object | true |
partition | Partition to which the message is being written | number |
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"]
Key | Description | Type |
---|---|---|
topic | Topic name of the message | string |
partition | Partition number where the message was published | long |
offset | Offset of the message within the partition | long |
timestamp | Timestamp of the message in milliseconds | long |
timeTaken | Time taken, in milliseconds | long |
error | Error message, if any, produced while publishing the message | string |
Example
{
"timeTaken": 155,
"rows": [
{
"id": 1,
"name": "PostgreSQL Tutorial",
"url": "https://www.postgresqltutorial.com"
}
]
}