代码之家  ›  专栏  ›  技术社区  ›  ca9163d9

如何设置schema.registry.URL?

  •  0
  • ca9163d9  · 技术社区  · 7 年前

    我正在测试发送通用记录。但是下面的代码

    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

    1 回复  |  直到 7 年前
        1
  •  1
  •   OneCricketeer Gabriele Mariotti    7 年前

    好, 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/

    documentation for more information

    推荐文章