使用spring-kafka我想将KTable
的结果(?)作为新事件发布到另一个主题中,但 topicB 的流从不接收事件。
如果我直接在mapValues()
上致电KTable
,似乎也会发生同样的情况。使用KTable
的内容时我错过了什么?
@Bean
KTable reportStream(StreamsBuilder builder, Engine engine) {
def stream = builder.stream("topicA")
.groupBy({ key, word -> word })
.windowedBy(SessionWindows.with(TimeUnit.SECONDS.toMillis(1)))
.aggregate(
new Initializer<Long>() {
@Override
Long apply() {
0
}
},
new Aggregator<String, String, Long>() {
@Override
Long apply(String key, String value, Long aggregate) {
def l = 1 + aggregate
return l
}
},
new Merger() {
@Override
Long apply(Object aggKey, Object aggOne, Object aggTwo) {
return aggOne + aggTwo
}
},
Materialized.with(Serdes.String(), Serdes.Long()))
stream.toStream().to("topicB")
stream
}
@Bean
KStream classificationStream(StreamsBuilder builder, Engine engine) {
builder.stream("topicB").mapValues({
println "topicB"
println it
})
}