Apache kafka 将Eclipse同上连接到ApacheKafka

Apache kafka 将Eclipse同上连接到ApacheKafka,apache-kafka,eclipse-hono,eclipse-ditto,eclipse-iot,Apache Kafka,Eclipse Hono,Eclipse Ditto,Eclipse Iot,我按照本文档中的说明将ApacheKafka连接到Eclipse同上 我不确定以下几点 1) 在授权上下文下[“同上:出站身份验证主题”,“…”] 2) “地址”:“主题/关键” 请让我知道他们!提前谢谢你 编辑: curl -X PUT 'http://localhost:8080/api/2/policies/org.eclipse.ditto:5100' -u 'ditto:ditto' -H 'Content-Type: application/json' -d '{ "entries

我按照本文档中的说明将ApacheKafka连接到Eclipse同上

我不确定以下几点

1) 在授权上下文下[“同上:出站身份验证主题”,“…”]

2) “地址”:“主题/关键”

请让我知道他们!提前谢谢你

编辑:

curl -X PUT 'http://localhost:8080/api/2/policies/org.eclipse.ditto:5100' -u 'ditto:ditto' -H 'Content-Type: application/json' -d '{
"entries": {
    "owner": {
        "subjects": {
            "nginx:ditto": {
                "type": "nginx basic auth user"
            }
        },
        "resources": {
            "thing:/": {
                "grant": [
                    "READ","WRITE"
                ],
                "revoke": []
            },
            "policy:/": {
                "grant": [
                    "READ","WRITE"
                ],
                "revoke": []
            },
            "message:/": {
                "grant": [
                    "READ","WRITE"
                ],
                "revoke": []
            }
        }
    }
}
}
请查找我用来连接Ditto和Kafka的命令

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": "MyKafkaConnection1",
        "connectionType": "kafka",
        "connectionStatus": "open",
        "uri": "tcp://radsah:password@localhost:9092",
        "specificConfig": {
        "bootstrapServers": "10.196.2.218:9092",
        "saslMechanism": "plain"
        },
        "failoverEnabled": true,
        "targets": [
              {
             "address": "digital-twins",
              "topics": [
               "_/_/things/twin/events",
               "_/_/things/live/messages"
                            ],
            "authorizationContext": ["ditto:outbound-auth-subject"]
        }],
        "mappingContext": {
            "mappingEngine": "JavaScript",
            "options": {
                "incomingScript": "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://localhost:8080/devops/piggyback/connectivity?timeout=8000
我已经使用Hono注册了一个设备,我正在将数据发送到同上。同上,成功接收数据。但我想把收到的数据发给卡夫卡

卡夫卡和同上成功建立了连接。但我不会在卡夫卡消费者“数字双胞胎”那里接受采访。我错过什么了吗

使用策略命令编辑:

curl -X PUT 'http://localhost:8080/api/2/policies/org.eclipse.ditto:5100' -u 'ditto:ditto' -H 'Content-Type: application/json' -d '{
"entries": {
    "owner": {
        "subjects": {
            "nginx:ditto": {
                "type": "nginx basic auth user"
            }
        },
        "resources": {
            "thing:/": {
                "grant": [
                    "READ","WRITE"
                ],
                "revoke": []
            },
            "policy:/": {
                "grant": [
                    "READ","WRITE"
                ],
                "revoke": []
            },
            "message:/": {
                "grant": [
                    "READ","WRITE"
                ],
                "revoke": []
            }
        }
    }
}
}

关于授权上下文,您可以查看一下。它必须包含在您的物品的策略或ACL中定义的主题

例如:

对象“foo:bar”的策略定义了主题“somePrefix:someValue”的整个对象的读取权限


在您提到的示例中,与“foo:bar”相关的事件将通过卡夫卡连接发布到您在“地址”字段中指定的主题。

您的问题是否已解决,或者我们是否需要进一步澄清?谢谢您的回答。我明白你的意思。但在某些方面仍然感到困惑。你知道有哪篇文章详细解释了连接的所有步骤吗?嗯,我不确定问题出在哪里,所以我不能给你提供任何文章。如果它仍然是授权上下文,那么它是特定于同上的内容。如果是地址部分,那么它是卡夫卡关系及其主题的特定部分。还有一些与你的问题无关的内容。你在公开场合也一样。您应该考虑更改默认密码。请再次查看我的响应。您在连接的authorizationContext中定义的主题必须出现在事物的策略中。在您的情况下,可以添加“nginx:ditto”作为授权上下文,或者添加“ditto:outbound auth subject”作为策略的主题。