从同上向Kafka发送消息时出错

时间:2019-08-14 22:09:45

标签: apache-kafka eclipse-hono eclipse-ditto eclipse-iot digital-twin

我成功连接了Eclipse Ditto和Kafka。我正在尝试通过Eclipse Hono将数据发送到Ditto。同上可以成功接收数据。但是Kafka使用者没有收到任何数据流。

请找到我使用的curl命令:

curl -X POST -i -u devops:foobar -H 'Content-Type: 
application/json' -d '{
"targetActorSelection": "/system/sharding/connection",
"headers": {
"aggregate": false
},
"piggybackCommand": {
"type": "connectivity.commands:createConnection",
"connection": {
    "id": "MyKafkaConnection100",
    "connectionType": "kafka",
    "connectionStatus": "open",
    "uri": "tcp://radsah:confirmmm@srvgal89.deri.ie:9092",
    "specificConfig": {
    "bootstrapServers": "srvgal89.deri.ie:9092",
    "saslMechanism": "plain"
    },
    "failoverEnabled": true,
    "targets": [
          {
         "address": "digital-twins",
          "topics": [
           "_/_/things/twin/events",
           "_/_/things/live/messages"
                        ],
        "authorizationContext": ["nginx:ditto"]
    }],
    "mappingContext": {
        "mappingEngine": "Java",
        "options": {
            "incoming": "function mapToDittoProtocolMsg(\n    headers,\n    textPayload,\n    bytePayload,\n    contentType\n) {\n\n    if (contentType !== \"application/json\") {\n        return null;\n    }\n\n    var jsonData = JSON.parse(textPayload);\n    var temperature = jsonData.temp;\n    var humidity = jsonData.hum;\n    \n    var path;\n    var value;\n    if (temperature != null && humidity != null) {\n        path = \"/features\";\n        value = {\n                temperature: {\n                    properties: {\n                        value: temperature\n                    }\n                },\n                humidity: {\n                    properties: {\n                        value: humidity\n                    }\n                }\n            };\n    } else if (temperature != null) {\n        path = \"/features/temperature/properties/value\";\n        value = temperature;\n    } else if (humidity != null) {\n        path = \"/features/humidity/properties/value\";\n        value = humidity;\n    }\n    \n    if (!path || !value) {\n        return null;\n    }\n\n    return Ditto.buildDittoProtocolMsg(\n        \"org.eclipse.ditto\",\n        headers[\"device_id\"],\n        \"things\",\n        \"twin\",\n        \"commands\",\n        \"modify\",\n        path,\n        headers,\n        value\n    );\n}"
        }
    }
}
}
}' http://srvgal90.deri.ie:8080/devops/piggyback/connectivity?timeout=8000

当我检查同上日志时,出现以下错误:

Log message

如果我的curl命令中缺少任何内容,请告诉我。除了在特定配置中添加saslMechanism之外,是否还需要添加其他任何内容。

0 个答案:

没有答案
相关问题