我正在尝试使用Apache Flink流API连接两个流,但没有任何内容加入,我在阅读文档后不知道,我做错了什么
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
DataStream<MyPojo2> source = env.fromCollection(Lists.newArrayList(new MyPojo2(1, "Ola"), new MyPojo2(2, "Ola")))
.assignTimestampsAndWatermarks(new IngestionTimeExtractor<MyPojo2>());
DataStream<MyPojo2> source2 = env.fromCollection(Lists.newArrayList(new MyPojo2(1, "Ela"), new MyPojo2(2, "Ela")))
.assignTimestampsAndWatermarks(new IngestionTimeExtractor<MyPojo2>());
DataStream<Tuple2<String, String>> joined = source.join(source2).where(keySelector).equalTo(keySelector).
window(GlobalWindows.create()).apply(joinFunction);
joined.print();
env.execute("Window");
关键功能只是myPojo.getFirst()
答案 0 :(得分:3)
除非您指定自定义GlobalWindows
,否则Trigger
窗口永远不会触发。在您的示例中,如果您使用TumblingEventTimeWindows.of(Time.seconds(5))
之类的内容,则应该看到结果。