Kafka MQTT Proxy

MQTT Proxy enables MQTT clients to use the MQTT 3.1.1 protocol to publish data directly to Apache Kafka.

⚠️ This does not convert kafka into a MQTT broker, this aims to provide a simple way to publish/persist IoT data to Kafka.

Run Kafka MQTT Proxy:

cd kafka-mqtt
docker compose up -d
cd ..

Publish a message:

mqtt-cli pub -h kafka-mqtt -p 1884 -t 'house/room/temperature' -m '20C'

Consuming the data:

kafka-cli kafka-console-consumer --from-beginning --group kafka-mqtt.consumer \
                                 --topic kafka-mqtt.temperature  \
                                 --bootstrap-server kafka1:9092 \
                                 --property print.key=true

Docker Compose

services:
  kafka-mqtt:
    image: confluentinc/cp-kafka-mqtt:${VERSION}
    environment:
      KAFKA_MQTT_BOOTSTRAP_SERVERS: kafka1:9092,kafka2:9092,kafka3:9092
      KAFKA_MQTT_TOPIC_REGEX_LIST: kafka-mqtt.temperature:.*temperature
      KAFKA_MQTT_LISTENERS: 0.0.0.0:1884
    ports:
      - "1884:1884"
    restart: on-failure

networks:
  default:
    external: true
    name: kafka-sandbox_network