Spring Kafka Streams:缺少类型信息

时间:2019-03-20 00:08:49

标签: spring-kafka

我已经用Kafka Streams设置了一个简单的Spring Boot App。 Spring Boot使用AutoConfiguration for Kafka创建了工厂。该消息是没有消息密钥的Json消息。使用以下配置会导致标题中出现“ No Type”信息。有输入吗?

spring.kafka.streams.properties.default.key.serde=org.apache.kafka.common.serialization.Serdes$StringSerde
spring.kafka.streams.properties.default.value.serde=org.springframework.kafka.support.serializer.JsonSerde
spring.kafka.consumer.properties.spring.json.key.default.type=java.lang.String
spring.kafka.consumer.properties.spring.json.value.default.type=com.abc.xyz.Person

错误

java.lang.IllegalStateException: No type information in headers and no default type provided
at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
at org.springframework.kafka.support.serializer.JsonDeserializer.deserialize(JsonDeserializer.java:353) ~[spring-kafka-2.2.4.RELEASE.jar:2.2.4.RELEASE]
at org.apache.kafka.streams.processor.internals.SourceNode.deserializeValue(SourceNode.java:63) ~[kafka-streams-2.0.1.jar:?]
at org.apache.kafka.streams.processor.internals.RecordDeserializer.deserialize(RecordDeserializer.java:66) [kafka-streams-2.0.1.jar:?]
at org.apache.kafka.streams.processor.internals.RecordQueue.addRawRecords(RecordQueue.java:97) [kafka-streams-2.0.1.jar:?]
at org.apache.kafka.streams.processor.internals.PartitionGroup.addRawRecords(PartitionGroup.java:117) [kafka-streams-2.0.1.jar:?]
at org.apache.kafka.streams.processor.internals.StreamTask.addRecords(StreamTask.java:677) [kafka-streams-2.0.1.jar:?]
at org.apache.kafka.streams.processor.internals.StreamThread.addRecordsToTasks(StreamThread.java:943) [kafka-streams-2.0.1.jar:?]
at org.apache.kafka.streams.processor.internals.StreamThread.runOnce(StreamThread.java:831) [kafka-streams-2.0.1.jar:?]
at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:767) [kafka-streams-2.0.1.jar:?]
at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:736) [kafka-streams-2.0.1.jar:?]

1 个答案:

答案 0 :(得分:0)

流不使用常规的consumer属性。

一些文档是否使您认为使用流时需要设置该属性?如果是这样,请打开GitHub问题,以便我们进行修复。

spring.kafka.streams.properties.spring.json.value.default.type=com.abc.xyz.Person

使用流时。

由于您没有JSON密钥序列,因此不需要key.default.type