【发布时间】:2019-04-04 22:15:10
【问题描述】:
我正在尝试使用 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
我该怎么办?我该如何解决?
【问题讨论】:
标签: apache-kafka spring-cloud avro spring-cloud-stream confluent-platform