请大家帮我看看下列问题是什么情况?

55e4ae8fbcf5776df58ec44b96b9a5d2.png为啥我这个窗口函数里面的 log一直没数据呢。上面那个有输出。 logger.info("kafkaStream Window....."); 没有。b6201aefc771a9013987fd7f7ce84913.png 看起来是执行了。

展开
收起
圆葱猪肉包 2023-03-27 13:46:40 237 分享 版权
2 条回答
写回答
取消 提交回答
  • /** *todo: 2023/3/20 23:14 九师兄 * * 测试数据 {"id":"11","name":"akka","password":"123","password1":"123","age":1} * 输出结果:1 分钟内收集到 student 的数据条数是:7 **/ public void timeWindowAll() throws Exception { StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setStreamTimeCharacteristic(TimeCharacteristic.ProcessingTime); //2.定义加载或创建数据源(source),监听9000端口的socket消息 DataStream textStream9000 = env.socketTextStream("localhost", 9992, "\n");

    SingleOutputStreamOperator<Student> student = textStream9000.map(string -> JSONObject.parseObject(string, Student.class));
    
    
    student.timeWindowAll(Time.seconds(5)).apply(new AllWindowFunction<Student, List<Student>, TimeWindow>() {
        @Override
        public void apply(TimeWindow window, Iterable<Student> values, Collector<List<Student>> out) throws Exception {
            ArrayList<Student> students = Lists.newArrayList(values);
            if (students.size() > 0) {
                System.out.println("1 分钟内收集到 student 的数据条数是:" + students.size());
                out.collect(students);
            }
        }
    }).print();
    
    env.execute("flink learning connectors kafka");
    

    }我测试是可以的 你对比一下。此回答整理自钉群“【③群】Apache Flink China社区”

    2023-03-28 10:54:30
    赞同 展开评论
  • GitHub https://github.com/co63oc/cloud

    Flink中如何使用TimeWindowAll https://www.yisu.com/zixun/525527.html

    2023-03-27 21:57:41
    赞同 展开评论

实时计算Flink版是阿里云提供的全托管Serverless Flink云服务,基于 Apache Flink 构建的企业级、高性能实时大数据处理系统。提供全托管版 Flink 集群和引擎,提高作业开发运维效率。

收录在圈子:
实时计算 Flink 版(Alibaba Cloud Realtime Compute for Apache Flink,Powered by Ververica)是阿里云基于 Apache Flink 构建的企业级、高性能实时大数据处理系统,由 Apache Flink 创始团队官方出品,拥有全球统一商业化品牌,完全兼容开源 Flink API,提供丰富的企业级增值功能。
还有其他疑问?
咨询AI助理