如何连接apache kafka到eclipse ditto?



我正在尝试连接apache kafka 2。

我遵循这个https://www.eclipse.org/ditto/connectivity-protocol-bindings-kafka2.html,所以我尝试用POST请求创建一个新的连接,如下所示:

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":"kafka123",
"connectionType":"kafka",
"connectionStatus":"open",
"failoverEnabled":true,
"uri":"tcp://localhost:9092",
"specificConfig":{
"bootstrapServers":"localhost:9092"
},
"sources":[
{
"addresses":["topic01"],
"consumerCount":1,
"qos":0,
"authorizationContext":["nginx:ditto"],
"enforcement":{
"input":"{{ header:device_id }}",
"filters":["{{ entity:id }}"]
},
"headerMapping":{
"topic01":"{{ header:topic01 }}",
"the-key":"{{ header:kafka.key }}"
},
"payloadMapping":["Ditto"],
"replyTarget":{
"enabled":true,
"address":"topic01",
"headerMapping":{

},
"expectedResponseTypes":[
"response",
"error",
"nack"
]
},
"acknowledgementRequests":{
"includes":[]
},
"declaredAcks":[]
}
]
}
}
}' 'http://localhost:8080/devops/piggyback/connectivity?timeout=10'

结果如下:

HTTP/1.1 408 Request Timeout
Server: nginx/1.21.6
Date: Wed, 18 May 2022 14:11:33 GMT
Content-Type: application/json
Content-Length: 4
Connection: keep-alive
correlation-id: 16231ebe-3cd1-4ec1-9f42-ad58b9b82d14
timeout: 10
response-required: false
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Expose-Headers: *
null%        

我不明白我做错了什么。我该如何解决?

我解决了检查ditto-connectivity日志(在docker上),我发现了一个关于java库的错误。为了解决这个问题,我重新安装了ditto (https://github.com/eclipse/ditto#getting-started)。

之后,在我的问题中写的命令工作了,我得到了200的响应。

似乎nginx无法将您的请求发送到ditto服务。可能有些同上服务没有运行,或者您试图使用错误的端口8080(如果您遵循同上设置的说明,它应该是30080)。请检查是否所有的ditto pod都在运行(使用'kubectl get pods'),以及你的ditto监听的端口(使用'kubectl get svc')

最新更新