我在笔记本电脑上旋转了 Docker 中的 Kafka(使用 docker-compose)。
之后,创建了新的 kafka 主题:
kafka-topics --zookeeper localhost:2181 --create --topic simple --replication-factor 1 --partitions 1
(尚未在模式注册表中创建模式)。
现在尝试生成(基于此示例 - 第 3 步 - https://docs.confluent.io/4.0.0/quickstart.html):
kafka-avro-console-producer \
--broker-list localhost:9092 --topic simple \
--property value.schema='{"type":"record","name":"myrecord","fields":[{"name":"f1","type":"string"}]}'
输入值:
{"f1": "value1"}
错误:
{"f1": "value1"}
org.apache.kafka.common.errors.SerializationException: Error registering Avro schema: {"type":"record","name":"myrecord","fields":[{"name":"f1","type":"string"}]}
Caused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (sun.net.www.protocol.http.HttpURLConnection$HttpInputStream); line: 1, column: 2]; error code: 50005
at io.confluent.kafka.schemaregistry.client.rest.RestService.sendHttpRequest(RestService.java:191)
at io.confluent.kafka.schemaregistry.client.rest.RestService.httpRequest(RestService.java:218)
at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:307)
at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:299)
at io.confluent.kafka.schemaregistry.client.rest.RestService.registerSchema(RestService.java:294)
at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.registerAndGetId(CachedSchemaRegistryClient.java:61)
at io.confluent.kafka.schemaregistry.client.CachedSchemaRegistryClient.register(CachedSchemaRegistryClient.java:100)
at io.confluent.kafka.serializers.AbstractKafkaAvroSerializer.serializeImpl(AbstractKafkaAvroSerializer.java:79)
at io.confluent.kafka.formatter.AvroMessageReader.readMessage(AvroMessageReader.java:166)
at kafka.tools.ConsoleProducer$.main(ConsoleProducer.scala:59)
at kafka.tools.ConsoleProducer.main(ConsoleProducer.scala)
如何解决这个问题?
可能是因为 Kafka 集群使用 SSL 但错误是虚假的吗?谢谢。