如何设置schema.registry.URL?

How to set schema.registry.URL?

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

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

returns 这个错误

HttpRequestException: [http://bing.com/] ServiceUnavailable[http://bing.com/] ServiceUnavailable -1

我应该设置什么值?

嗯,bing.com 不是 架构注册表

您需要下载 Confluent OSS Distribution 并配置 运行(假设 Linux,但 bin\windows\ 否则有效)

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

然后你会使用类似 http://schema-registry.server.name:8081/

参考documentation for more information