Consume
Consume messages from one or more Kafka topics.
type: "io.kestra.plugin.kafka.Consume"
Examples
Consome data from a Kafka topic
id: kafka_consume
namespace: company.team
tasks:
- id: consume
type: io.kestra.plugin.kafka.Consume
topic: test_kestra
properties:
bootstrap.servers: localhost:9092
serdeProperties:
schema.registry.url: http://localhost:8085
keyDeserializer: STRING
valueDeserializer: AVRO
Connect to a Kafka cluster with SSL.
id: kafka_consume
namespace: company.team
tasks:
- id: consume
type: io.kestra.plugin.kafka.Consume
properties:
security.protocol: SSL
bootstrap.servers: localhost:19092
ssl.key.password: my-ssl-password
ssl.keystore.type: PKCS12
ssl.keystore.location: my-base64-encoded-keystore
ssl.keystore.password: my-ssl-password
ssl.truststore.location: my-base64-encoded-truststore
ssl.truststore.password: my-ssl-password
topic:
- kestra_workerinstance
keyDeserializer: STRING
valueDeserializer: STRING
Consume data from a Kafka topic and write it to a JSON file
id: consume-kafka-messages
namespace: company.team
tasks:
- id: consume
type: io.kestra.plugin.kafka.Consume
topic: topic_test
properties:
bootstrap.servers: localhost:9093
auto.offset.reset: earliest
pollDuration: PT20S
maxRecords: 50
keyDeserializer: STRING
valueDeserializer: JSON
- id: write_json
type: io.kestra.plugin.serdes.json.IonToJson
newLine: true
from: "{{ outputs.consume.uri }}"
Properties
properties *Requiredobject
Kafka connection properties.
The bootstrap.servers
property is a minimal required configuration to connect to a Kafka topic.
This property can reference any valid Consumer Configs or
Producer Configs as key-value pairs.
If you want to pass a truststore or a keystore, you must provide a base64 encoded string for ssl.keystore.location
and ssl.truststore.location
.
groupId string
Kafka consumer group ID.
Using a consumer group, we will fetch only records that haven't been consumed yet.
keyDeserializer string
STRING
STRING
INTEGER
FLOAT
DOUBLE
LONG
SHORT
BYTE_ARRAY
BYTE_BUFFER
BYTES
UUID
VOID
AVRO
JSON
The deserializer used for the key.
Possible values are: STRING
, INTEGER
, FLOAT
, DOUBLE
, LONG
, SHORT
, BYTE_ARRAY
, BYTE_BUFFER
, BYTES
, UUID
, VOID
, AVRO
, JSON
.
maxDuration string
duration
The maximum duration to wait for new records before stopping the consumption process.
It's a soft limit evaluated every second.
maxRecords integerstring
The maximum number of records to fetch before stopping the consumption process.
It's a soft limit evaluated every second.
onSerdeError Non-dynamicKafkaConsumerInterface-OnSerdeError
On serde error.
Set the behavior wanted when valueDeserializer is JSON and a serde error has occurred :
- SKIPPED : all invalid messages will be skipped
- STORE : messages will be ignored and stored as a file
- DLQ : messages will be ignored and sent to the DLQ specified in topic
partitions array
Topic partitions to consume messages from.
Manually assign a list of partitions to the consumer.
pollDuration string
PT5S
duration
How often to poll for a record.
If no records are available, the maximum wait duration to wait for new records.
serdeProperties object
{}
Serializer configuration
Configuration that will be passed to serializer or deserializer. The avro.use.logical.type.converters
is always passed when you have any values set to true
.
since string
Timestamp of a message to start consuming messages from.
By default, we consume all messages from the topics with no consumer group or depending on the configuration of the auto.offset.reset
property. However, you can provide an arbitrary start time.
This property is ignored if a consumer group is used.
It must be a valid ISO 8601 date.
topic Non-dynamicobject
Kafka topic(s) to consume messages from.
It can be a string or a list of strings to consume from one or multiple topics.
topicPattern string
Kafka topic pattern to consume messages from.
Consumer will subscribe to all topics matching the specified pattern to get dynamically assigned partitions.
valueDeserializer string
STRING
STRING
INTEGER
FLOAT
DOUBLE
LONG
SHORT
BYTE_ARRAY
BYTE_BUFFER
BYTES
UUID
VOID
AVRO
JSON
The deserializer used for the value.
Possible values are: STRING
, INTEGER
, FLOAT
, DOUBLE
, LONG
, SHORT
, BYTE_ARRAY
, BYTE_BUFFER
, BYTES
, UUID
, VOID
, AVRO
, JSON
.
Outputs
messagesCount integer
Number of messages consumed from a Kafka topic.
uri string
uri
URI of a file in Kestra's internal storage containing the messages.
Definitions
io.kestra.plugin.kafka.KafkaConsumerInterface-OnSerdeError
topic string
Topic used when DLQ has been chosen.
type string
SKIPPED
SKIPPED
DLQ
STORE
Behavior in case of serde error.