何时在Flink中使用CoProcess函数? [英] When to use CoProcess Function in Flink?

查看:79
本文介绍了何时在Flink中使用CoProcess函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想了解何时在Flink中使用CoProcessFunction的用例.通过示例进行解释将有助于我更好地理解该概念.

I am just trying to understand the use case when to use CoProcessFunction in Flink. Explanation with an example would help me to understand the concept better.

推荐答案

CoProcessFunction与RichCoFlatMap类似,但是还可以使用计时器.例如,计时器可用于使过期密钥的状态到期,或在保持活动消息未能到达时发出警报.

A CoProcessFunction is similar to a RichCoFlatMap, but with the addition of also being able to use timers. The timers are useful for expiring state for stale keys, or for raising alarms when keep alive messages fail to arrive, for example.

CoProcessFunction允许您使用一个流来影响另一个流的处理方式,或丰富另一个流.例如,一个电子商务站点可能有一个订单事件流和一个装运事件流,他们想为放置24小时后仍未装运的订单创建一个事件流.这两个流可以由orderId键控,并连接在一起.当订单到达时,它将以键控状态进行记录,并创建一个计时器以在24小时后触发.装运事件到达时,状态和计时器将清除.如果计时器确实触发,则使用该状态将订单发送到未履行的订单服务.

A CoProcessFunction allows you to use one stream to influence how another is processed, or to enrich another stream. For example, an e-commerce site might have a stream of order events and a stream of shipment events, and they want to create a stream of events for orders that haven't shipped with 24 hours of the order being placed. The two streams can be keyed by the orderId, and connected together. As an order arrives it's recorded in keyed state, and a timer is created to fire 24 hours later. When a shipment event arrives, the state and timer are cleared. If a timer does fire, the state is used to send the order out to the unfilled order service.

有关此内容以及代码示例的更多信息,请参见处理功能以及这些教程随附的实验.

For more on this, and examples with code, see connected streams and process function and the labs that accompany those tutorials.

这篇关于何时在Flink中使用CoProcess函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆