【发布时间】:2021-01-10 17:00:59
【问题描述】:
我有一个项目使用 Spring 云流和 Kafka Streams binder。对于流的输出,我使用 Avro,并使用 Confluent(io.confluent.kafka.streams.serdes.avro.SpecificAvroSerde) 提供的 Serde。
我可以将它与 Confluent Schema Registry 一起使用。序列化和反序列化正确进行。
但是,我想看看我们是否可以使用Spring Cloud Schema Registry Server 而不是 Confluent 。我配置了一个独立的 Schema Registry 服务器并将我的项目中的模式注册表设置为它(更改了 schemaRegistryClient.endpoint 和 schema.registry.url 属性)。
当我试用它时,似乎 Spring Cloud 能够与独立服务器一起工作。它将资源文件夹中可用的模式注册为 .avsc 文件。但是,当我发送消息时,似乎 Confluent 序列化程序继续将其作为 Confluent Schema Registry (它具有与 Spring Schema Registry 不同的 REST 端点)。结果,它得到一个 405 响应代码。
我们得到以下异常(部分堆栈跟踪)
org.apache.kafka.common.errors.SerializationException: Error registering Avro schema: <my-avro-schema>
Caused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: Unexpected character ('<' (code 60)): expected a valid value (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
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:230)
在我看来有两种可能:
- Spring Schema Registry Server 只能使用 Spring 提供的内容类型(指定为
content-type: application/*+avro),不能使用 Confluent 提供的本机 Serde,或者 - 项目配置存在问题。
谁能帮我弄清楚是哪一个?如果是第二个,谁能指出哪里出了问题?
【问题讨论】:
标签: spring-kafka spring-cloud-stream confluent-schema-registry spring-cloud-stream-binder-kafka