KQ encapsulates Kafka messages using kq.Message namedtuples, which have the following fields:

  • topic (str): Name of the Kafka topic.
  • partition (int): Kafka topic partition.
  • offset (int): Partition offset.
  • key (bytes | None): Kafka message key.
  • value (bytes): Kafka message payload.
from collections import namedtuple

Message = namedtuple(

Raw Kafka messages are converted into these namedtuples, which are then sent to workers (and also to callback functions if defined).