You can use the Kafka source connector, which will transfer data from the MQTT broker, such as Mosquitto, to the Kafka cluster. See https://github.com/evokly/kafka-connect-mqtt
The easiest way to start the connector is in offline mode, where one instance will be launched on the Kafka cluster on one node. You can also run it in distributed mode (albeit with a much larger configuration), and this will distribute the connector in the cluster for more bandwidth. In distributed mode, you can develop a topology that allows horizontal scaling, parallel bandwidth and high availability. Implementing additional warranties requires additional load balancers, several MQTT brokers, and the latest will and testament scenarios to fix connector failures, but this is probably not the case.
Using the connectivity approach takes advantage of the Kafka cluster, ensuring that your connector is alive and restarting it if necessary. Distributed mode offers even more benefits.
source share