7.6. 使用 Kafka Streams 应用程序中的 schema
此流程描述了如何配置使用 Java 编写的 Kafka Streams 客户端,以使用来自 Service Registry 的 Apache Avro 模式。
先决条件
- 已安装 Service Registry
- 模式使用 Service Registry 注册
流程
使用 Service Registry URL 创建并配置 Java 客户端:
String registryUrl = "https://registry.example.com/apis/registry/v2"; RegistryService client = RegistryClient.cached(registryUrl);
String registryUrl = "https://registry.example.com/apis/registry/v2"; RegistryService client = RegistryClient.cached(registryUrl);
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 配置 serializer 和 deserializer:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 创建 Kafka Streams 客户端:
KStream<String, LogInput> input = builder.stream( INPUT_TOPIC, Consumed.with(Serdes.String(), logSerde) );
KStream<String, LogInput> input = builder.stream( INPUT_TOPIC, Consumed.with(Serdes.String(), logSerde) );
Copy to Clipboard Copied! Toggle word wrap Toggle overflow