如何将 Spring Cloud Stream Kafka 与 Confluent Schema Registry 一起使用?

How to use Spring Cloud Stream Kafka with Confluent Schema Registry?

我正在寻找一个简单可行的示例,它使用 Spring Cloud Stream Kafka 和 Confluent Schema Registry(生产者和消费者)。我在 spring cloud stream reference guide 之后添加了以下代码,但它没有用。谁能指导我如何实现它?非常感谢!

@Bean
public SchemaRegistryClient schemaRegistryClient(@Value("${spring.cloud.stream.schemaRegistryClient.endpoint}") String endpoint){
  ConfluentSchemaRegistryClient client = new ConfluentSchemaRegistryClient();
  client.setEndpoint(endpoint);
  return client;
}

Here 是一个简单的示例,显示了 spring 具有 Avro 序列化的云流。此示例对模式注册表进行存根和模拟。

您的 bean 看起来正确,您只需要 application.properties(或 application.yml)

中的 "spring.cloud.stream.schemaRegistryClient.endpoint" 的 运行 模式注册表和配置

我尝试了 this schema registry sample,它对我有用。自述文件中提到了所有说明。