forked from confluentinc/demo-scene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_mqtt_source_local.sh
executable file
·28 lines (26 loc) · 1.13 KB
/
create_mqtt_source_local.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
source .env
echo "Waiting for Kafka Connect to start listening on localhost:8083 ⏳"
while : ; do
curl_status=$(curl -s -o /dev/null -w %{http_code} http://localhost:8083/connectors)
echo -e $(date) " Kafka Connect listener HTTP state: " $curl_status " (waiting for 200)"
if [ $curl_status -eq 200 ] ; then
break
fi
sleep 5
done
#
curl -X PUT -H "Content-Type:application/json" http://localhost:8083/connectors/source-mqtt-01/config \
-d '{
"connector.class" : "io.confluent.connect.mqtt.MqttSourceConnector",
"mqtt.server.uri" : "${file:/data/mqtt.credentials:MQTT_URL}",
"mqtt.password" : "${file:/data/mqtt.credentials:MQTT_PASSWORD}",
"mqtt.username" : "${file:/data/mqtt.credentials:MQTT_USERNAME}",
"mqtt.topics" : "owntracks/#",
"kafka.topic" : "data_mqtt",
"key.converter": "org.apache.kafka.connect.storage.StringConverter",
"value.converter": "org.apache.kafka.connect.converters.ByteArrayConverter",
"tasks.max" : "1",
"confluent.topic.bootstrap.servers" : "kafka-1:39092,kafka-2:49092,kafka-3:59092",
"confluent.topic.replication.factor" : "1"
}'