如何设置schema.registry.url?

ehxuflar  于 2021-06-07  发布在  Kafka
关注(0)|答案(1)|浏览(594)

我正在测试发送genericord。但是下面的代码

let fullName = "Test k"
let uniEncoding = new UnicodeEncoding()
let str = uniEncoding.GetBytes("abcdefg")

use ms = new MemoryStream()
ms.Write(str, 0, str.Length)
let content = ms.ToArray()

let config = new Dictionary<string, Object>()
config.Add("bootstrap.servers", "10.0.0.2:9092")
config.Add("schema.registry.url", "http://bing.com")
let s = Schema.Parse(
            """{
                "namespace": "nnnnnnnn",
                "type": "record",
                "name": "fffffnnnnnn",
                "fields": [
                    {"name": "file_name", "type": "string"},
                    {"name": "time",  "type": "string"},
                    {"name": "content", "type": "bytes"}
                ]
                }""") :?> RecordSchema
use producer = new Producer<string, GenericRecord>(
                 config, new AvroSerializer<string>(), new AvroSerializer<GenericRecord>())
let record = new GenericRecord(s)
record.Add("file_name", fullName)
record.Add("time", DateTimeOffset.Now.ToString())
record.Add("content", content)
let dr = producer.ProduceAsync("Topic1", fullName, record).Result // error

0 // return an integer exit code

返回此错误
httprequestexception:[http://bing.com/]服务不可用[http://bing.com/]服务不可用-1
我应该设置什么值?

wnavrhmk

wnavrhmk1#

好, bing.com 不是架构注册表
您需要下载confluent oss发行版并进行配置和运行(假设是linux,但是 bin\windows\ 工程(其他)

<confluent_home>/bin/schema-registry-start <confluent_home>/etc/schema-registry/schema-registry.properties

那你就用 http://schema-registry.server.name:8081/ 有关更多信息,请参阅文档

相关问题