【问题标题】:Can we use standalone Spring Cloud Schema Registry with Confluent's KafkaAvroSerializer?我们可以将独立的 Spring Cloud Schema Registry 与 Confluent 的 KafkaAvroSerializer 一起使用吗?
【发布时间】: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.endpointschema.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)

在我看来有两种可能:

  1. Spring Schema Registry Server 只能使用 Spring 提供的内容类型(指定为 content-type: application/*+avro),不能使用 Confluent 提供的本机 Serde,或者
  2. 项目配置存在问题。

谁能帮我弄清楚是哪一个?如果是第二个,谁能指出哪里出了问题?

【问题讨论】:

    标签: spring-kafka spring-cloud-stream confluent-schema-registry spring-cloud-stream-binder-kafka


    【解决方案1】:

    每个架构注册表提供程序都需要一个专有的 SerDe 库。例如,如果你想integrate AWS Glue Schema Registry with Kafka,那么你需要亚马逊的 SerDe 东西。因此,Confluent 的 SerDe 库需要在 schema.registry.url 属性中指定的地址处使用 Confluent 的 Schema Registry。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-26
      • 2019-11-06
      • 2019-07-21
      • 2019-07-21
      • 2023-01-11
      • 1970-01-01
      • 2021-09-03
      • 1970-01-01
      相关资源
      最近更新 更多