KafkaTrigger
class KafkaTrigger(
conn: KafkaConn,
topic: str,
data_format: KafkaMessageFormatSpec,
schema: str,
group_id: str | None = None,
time_rollover_secs: PositiveInt = 60,
size_rollover_mb: PositiveInt | None = None,
messages_rollover: PositiveInt | None = None,
dlq_topic: str | None = None,
start: datetime | None = None,
end: datetime | None = None,
)
Bases: StageTrigger
Categories: trigger
A StageTrigger that consumes messages from a Kafka topic and stages them.
This trigger connects to a Kafka cluster, consumes messages from a specified topic, and uses rollover conditions (time, size, and message count) to buffer and stage the data.
Initialize a KafkaTrigger instance.
Parameters
connThe Kafka consumer connection configuration.
topicThe Kafka topic to consume from.
data_formatThe data format of the messages ("avro", "json", "protobuf").
schemaThe schema string for deserializing messages.
group_idOptional Kafka consumer group ID.
schemaOptional schema name for AWS Glue Schema Registry.
time_rollover_secsThe timeout in seconds before staging and committing a message buffer. Defaults to 60.
size_rollover_mbOptional size-based rollover configuration. Size is specified in megabytes.
messages_rolloverOptional message count-based rollover configuration.
dlq_topicOptional dead-letter queue topic.
startOptional datetime for the trigger to start working.
endOptional datetime for the trigger to stop working.
Properties
connKafkaConnKafka consumer connection configuration.
data_formatKafkaMessageFormatSpecData format of the messages ("avro", "json", "protobuf").
dlq_topicstr | NoneDead-letter queue topic.
enddatetime | Nonegroup_idstr | NoneKafka consumer group ID.
messages_rolloverPositiveInt | NoneMessage count-based rollover configuration.
outdict[int, str] | NoneReturns a mapping of positional index to table name for the outputs produced by this trigger, or None when the StageTrigger implementation only supports generating a single table.
schemastrSchema string for deserializing messages.
size_rollover_mbPositiveInt | NoneSize-based rollover configuration. Size is specified in megabytes.
startdatetime | Nonetime_rollover_secsintTimeout in seconds for consuming each message.
topicstrKafka topic to consume from.
Methods
rundef run(context: StageTriggerContext)
Run the Kafka stage trigger to consume messages, buffer them, and stage them based on rollover conditions.
Parameters:
contextThe StageTriggerContext instance.