Quickly test MQTT Source connector.
Simply run:
$ ./mqtt.sh
Note: The ./password
file was created with (myuser/mypassword
) and command:
$ mosquitto_passwd -c password myuser
Creating MQTT Source connector
$ curl -X PUT \
-H "Content-Type: application/json" \
--data '{
"connector.class": "io.confluent.connect.mqtt.MqttSourceConnector",
"tasks.max": "1",
"mqtt.server.uri": "tcp://mosquitto:1883",
"mqtt.topics":"my-mqtt-topic",
"kafka.topic":"mqtt-source-1",
"mqtt.qos": "2",
"mqtt.username": "myuser",
"mqtt.password": "mypassword",
"confluent.license": "",
"confluent.topic.bootstrap.servers": "broker:9092",
"confluent.topic.replication.factor": "1"
}' \
http://localhost:8083/connectors/source-mqtt/config | jq .
Send message to MQTT in my-mqtt-topic topic
$ docker exec mosquitto sh -c 'mosquitto_pub -h localhost -p 1883 -u "myuser" -P "mypassword" -t "my-mqtt-topic" -m "sample-msg-1"'
Verify we have received the data in mqtt-source-1 topic
$ docker exec broker kafka-console-consumer -bootstrap-server broker:9092 --topic mqtt-source-1 --from-beginning --max-messages 1
N.B: Control Center is reachable at http://127.0.0.1:9021