I am trying to join two streams in Kafka like following code.
@Bean
public KTable<String, String> stream(StreamsBuilder builder) {
KeyValueBytesStoreSupplier store =
Stores.persistentKeyValueStore("words");
JsonSerde<String> wordSerde = new JsonSerde<>(String.class);
KStream<String, String> stream = builder
.stream("topic-a", Consumed.with(Serdes.String(), wordSerde));
return stream.join(
builder.stream("topic-b"),
(w1, w2) -> w1+w2,
JoinWindows.of(Duration.ofSeconds(10)),
StreamJoined.with(Serdes.String(), wordSerde, wordSerde))
.toTable(Materialized.<String, String>as(store)
.withKeySerde(Serdes.String())
.withValueSerde(wordSerde));
}
but when I'm trying to read from KeyValueBytesStoreSupplier
it is just only reading from topic-a
.
updated:
I published some messages to both topics.
for example in topic-a
I sent Hi message and same message in topic-b
what thing that I expect is merging two words together. HiHi
@PostMapping("publish/{word}")
fun publishEvent2(@PathVariable(value = "word") event: String){
kafkaTemplate2.send("topic-a", event,event)
}
Did I miss somethings?