我目前无能力反序列化 avro PRIMITIVE 密钥在 KSTREAM 应用程序中
使用 avro 模式编码的密钥(在模式注册表中注册),
当我使用 kafka-avro-console-consumer 时,我可以看到密钥已正确反序列化
但不可能让它在 KSTREAM 应用程序中运行
密钥的 avro 模式是一个原语:
{"type":"string"}
我已经遵循了 confluence 的文档
final Serde<V> valueSpecificAvroSerde = new SpecificAvroSerde<>();
final Map<String, String> serdeConfig = Collections.singletonMap(SCHEMA_REGISTRY_URL_CONFIG, schemaRegistryUrl);
valueSpecificAvroSerde.configure(serdeConfig, false);
final Serdes.StringSerde keySpecificAvroSerde = new Serdes.StringSerde();
keySpecificAvroSerde.configure(serdeConfig, true);
Consumed<String, totoAvro> inputConf = Consumed.with(keySpecificAvroSerde, valueSpecificAvroSerde);
final KStream<String, totoAvro> mystream = builder.stream("name topic", inputConf);
mystream.peek((key, value) -> logger.info("topic KEY :" + key))
它对于值来说工作得很好,但是键将是一个包含模式注册表中的字节的字符串,而不仅仅是“卷轴”键
https://docs.confluence.io/current/schema-registry/serializer-formatter.html#wire-format https://docs.confluent.io/current/schema-registry/serializer-formatter.html#wire-format
所以字符串键是/§/./11016015201,但我想要卷轴值:1016015201
如果我打印字符串内的字节,它是 [ 0x00 0x00 0x00 0x02 0x31 0x14 0x31 0x30 0x31 0x36 0x30 0x31 0x35 0x32 0x30 0x31 ]