apache-kafka - Confluent Kafka Avro 序列化器和 Spring Cloud
问题描述
我正在尝试使用 Spring Cloud 和 Kafka Avro Serializer 在 Kafka 上生成一个事件。
在我的 application.yml 中,我有以下配置,但是当 Serializer 尝试生成消息时,它生成为字节,因为传递给 KafkaSerializer 中的 getScheme 方法的对象是字节数组,它不是 GenericRecord。我认为我需要 Spring Cloud 中的特定 MessageConverter,但我没有找到。
cloud:
stream:
kafka:
binder:
brokers:
- 'localhost:9092'
useNativeDecoding: true
bindings:
Ptr-output:
producer:
configuration:
schema.registry.url: 'http://localhost:8081'
key.serializer: org.apache.kafka.common.serialization.StringSerializer
value.serializer: com.abc.message.ptr.KafkaSerializer
schemaRegistryClient:
endpoint: 'http://localhost:8081'
bindings:
Ptr-output:
contentType: application/*+avro
destination: Ptr
schema:
avro:
schema-locations: 'classpath:avro/Ptr.avsc'
dynamic-schema-generation-enabled: false
我能怎么做?我该如何解决?
解决方案
尝试将序列化程序设置为io.confluent.kafka.serializers.KafkaAvroDeserializer
推荐阅读
- pine-script - 字符串数组作为输入选项?
- css - 关闭按钮位置错误
- c++ - 多线程不起作用(不比单线程快)
- reactjs - 如何为一组组件创建一个动态的 React 钩子数组
- html - Visual Studio 代码中的 HTML
- git - 如何使用 git log --since 来产生可靠的结果
- mysql - 在具有 where 条件的重复键上
- python - 向请求中添加新字段和值 - Django - Django Rest Framework (viewset, serializer)
- git - Git pre-merge-commit 钩子:如何在合并期间忽略文件?
- python - 合并多个数据框保留列并用 NaN 填充其余部分