We have theses POJOs:
@Data
@NoArgsConstructure
@AllArgsConstructure
class MyPost {
private String content;
private SeenInfo seenInfo;
}
@Data
@NoArgsConstructure
@AllArgsConstructure
class SeenInfo {
private Integer seenCount;
//other fields...
}
and this left-join process in our application:
@Bean
public Function<KStream<String, MyPost>, Function<KStream<String, SeenInfo>, KStream<String, MyPost>>> joinProcess(Map<String, String> schemaConfig) {
return postStream ->
seenInfoStream -> {
SpecificAvroSerde<MyPost> postSerde = new SpecificAvroSerde<>();
SpecificAvroSerde<SeenInfo> seenInfoSerde = new SpecificAvroSerde<>();
postSerde.configure(schemaConfig, true);
seenInfoSerde.configure(schemaConfig, true);
return postStream.leftJoin(seenInfoStream,
(p, s) -> {
p.setSeenInfo(s);
return p;
},
JoinWindows.of(Duration.ofMinutes(5)),
StreamJoined.with(Serdes.String(),
postSerde,
seenInfoSerde));
};
}
Problem One:
When MyPost and SeenInfo matching values are present within 5 minutes, the join process produces two messages:
Message1: MyPost={ "content": "some text", "seenInfo": null}
Message2: MyPost={ "content": "some text", "seenInfo": { "seenCount": 1, ...}}
Problem Two:
If MyPost is present and SeenInfo is not, the join process will not return any data.
We Expect: Message: MyPost={ "content": "some text", "seenInfo": null}
What should we do to solve this problem?