Skip to content

Kafka Connector

The Kafka connector reads from and writes to Apache Kafka topics, with optional SASL/PLAIN authentication.

Connector Types:

  • KafkaReader - Consume messages from a topic as part of a consumer group
  • KafkaWriter - Produce messages to a topic

Consume from a topic using a consumer group:

{
"type": "KafkaReader",
"config": {
"brokers": ["localhost:9092"],
"topic": "sensor-events",
"groupId": "meddle-consumers"
}
}
{
"type": "KafkaReader",
"config": {
"brokers": [
"kafka-1.example.com:9092",
"kafka-2.example.com:9092",
"kafka-3.example.com:9092"
],
"topic": "factory.events",
"groupId": "meddle-factory-consumers",
"username": "kafka_user",
"password": "kafka_password"
}
}

Produce messages to a topic:

{
"type": "KafkaWriter",
"config": {
"brokers": ["localhost:9092"],
"topic": "processed-events"
}
}
{
"type": "KafkaWriter",
"config": {
"brokers": [
"kafka-1.example.com:9092",
"kafka-2.example.com:9092"
],
"topic": "factory.processed",
"username": "kafka_user",
"password": "kafka_password"
}
}
  • brokers: List of bootstrap broker addresses (host:port)
  • topic: Kafka topic name
  • groupId: (Reader) Consumer group identifier
  • username: (Optional) SASL/PLAIN username
  • password: (Optional) SASL/PLAIN password

The groupId controls how Kafka partitions are distributed across readers:

  • Multiple readers with the same groupId share partitions for horizontal scaling.
  • Multiple readers with different groupId values each receive a full copy of the topic stream.
  • Offsets are committed per consumer group; restarts resume from the last committed offset.

The writer uses the LeastBytes balancer, which spreads messages across partitions to minimise per-broker load. Messages within a single Meddle pipeline are not guaranteed to land on the same partition.

  • Authentication is enabled only when both username and password are supplied.
  • The connector uses SASL/PLAIN. Pair with TLS at the network layer (broker config) when running in production.
  • MQTT - Lightweight pub/sub for devices
  • AMQP - RabbitMQ alternative
  • NATS - Cloud-native pub/sub alternative