-
Notifications
You must be signed in to change notification settings - Fork 24
/
config.js
91 lines (78 loc) · 3 KB
/
config.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
"use strict";
module.exports = {
// mqtt connection options
mqtt: { // # see https://github.com/mqttjs/MQTT.js#mqttclientstreambuilder-options
url: null,
options: {
clientId: "example-client",
username: "example",
password: "1234",
host: "some.mqtt.server.com",
port: 8080,
protocolId: "MQTT",
protocolVersion: 4,
}
},
// kafka connection options
kafka: { // # see https://github.com/nodefluent/node-sinek/blob/master/lib/librdkafka/README.md
logger: undefined,
noptions: {
//"debug": "all",
"metadata.broker.list": "localhost:9092",
"client.id": "mqtt-bridge-example-client",
"event_cb": true,
"compression.codec": "none",
"retry.backoff.ms": 200,
"message.send.max.retries": 10,
"socket.keepalive.enable": true,
"queue.buffering.max.messages": 100000,
"queue.buffering.max.ms": 1000,
"batch.num.messages": 1000000,
//"security.protocol": "sasl_ssl",
//"ssl.key.location": path.join(__dirname, "../certs/ca-key"),
//"ssl.key.password": "nodesinek",
//"ssl.certificate.location": path.join(__dirname,"../certs/ca-cert"),
//"ssl.ca.location": path.join(__dirname,"../certs/ca-cert"),
//"sasl.mechanisms": "PLAIN",
//"sasl.username": "admin",
//"sasl.password": "nodesinek",
"api.version.request": true,
},
tconf: {
"request.required.acks": 1,
}
},
// declares on which target kafka topic a mqtt message should be routed to (based on the mqtt topic)
routing: {
//"*": "*", // from all to all (indiviudally 1:1)
//"*": "kafka-test", // from all to single kafka-test topic
//"mqtt-topic": "kafka-topic", // from mqtt-topic to kafka-topic only
"*": "mqtt-bridge-example"
},
// if routed messages should be logged to debug
logMessages: true,
// declares how an mqtt topic name should be split (/) to fit to the kafka topic naming conventions
kafkaTopicDelimiter: "-",
// gives you the option to alter mqtt messages before they are consumed (routed)
subscribeEtl: (topic, message, packet, callback) => {
// first param is an error, if you pass one, we will omit the message
callback(null, {
topic,
message,
});
},
// gives you the option to alter kafka messages before they are produced
produceEtl: (topic, message, key, callback) => {
// first param is an error, if you pass one, we will omit the message
callback(null, {
topic,
message, // you can pass an object, will be turned into a string
key, // default uuid.v4
partition: null, // default null
});
},
// the bridge starts an http server
http: {
port: 3967,
},
};