Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Serialization 如何设置schema.registry.URL?_Serialization_F#_Apache Kafka_Avro_Confluent Schema Registry - Fatal编程技术网

Serialization 如何设置schema.registry.URL?

Serialization 如何设置schema.registry.URL?,serialization,f#,apache-kafka,avro,confluent-schema-registry,Serialization,F#,Apache Kafka,Avro,Confluent Schema Registry,我正在测试发送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&l

我正在测试发送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
让fullName=“测试k”
让uniEncoding=newunicodeincoding()
让str=uniEncoding.GetBytes(“abcdefg”)
使用ms=newmemoryStream()
ms.Write(str,0,str.Length)
让内容=ToArray女士()
让config=newdictionary()
config.Add(“bootstrap.servers”,“10.0.0.2:9092”)
config.Add(“schema.registry.url”http://bing.com")
设s=Schema.Parse(
"""{
“命名空间”:“nnnnnnnn”,
“类型”:“记录”,
“名称”:“FFFFF NNNNNN”,
“字段”:[
{“名称”:“文件名”,“类型”:“字符串”},
{“名称”:“时间”,“类型”:“字符串”},
{“名称”:“内容”,“类型”:“字节”}
]
}“”:?>RecordSchema
使用生产者=新生产者(
配置,新的AvroSerializer(),新的AvroSerializer())
let record=新的通用记录
添加(“文件名”,全名)
record.Add(“time”,DateTimeOffset.Now.ToString())
记录。添加(“内容”,内容)
让dr=producer.ProduceAsync(“Topic1”,全名,记录)。结果//错误
0//返回整数退出代码
返回此错误

HttpRequestException:[ServiceUnavailable[ServiceUnavailable-1


我应该设置什么值?

嗯,
bing.com
不是模式注册表

您需要下载Confluent OSS发行版并进行配置和运行(假设Linux,但
bin\windows\
不起作用)

/bin/schema registry start/etc/schema registry/schema-registry.properties
然后您将使用类似
http://schema-registry.server.name:8081/


请参阅

有没有一种方法不需要Confluent OSS distributrion,因为我使用的是
GenericRecord
?Confluent平台与您使用的Avro数据类型无关……您的代码仍然要求您运行一台能够接受包含Avro模式的请求的服务器。我使用的是Kafka发送字符串,确实如此不需要Confluent平台。仅使用avro时需要它吗?Confluent的Kafka安装仍然支持字符串,它不是不同的Kafka版本。因此,不需要,它只需要使用架构注册表,而架构注册表恰好为您提供了avro序列化程序支持。有关完整信息,请参阅
<confluent_home>/bin/schema-registry-start <confluent_home>/etc/schema-registry/schema-registry.properties