用Flink实现的一个实时订单对账功能, Flink的双流实时对账

1.为什么业务订单数据不用Mysql之类的强事务性数据库监控反而用Flink的实时?

一般这种涉及到订单的数据流都要用mysql监控实现,但是鉴于减少mysql的数据库压力和提高更实时性,

可以考虑用Flink实时的数据流做实时的参考

2.如何处理乱序数据?

使用watermark水位保证第一层数据延迟.PS:这里的水位不能设置太长延迟

使用processfuntion更加灵活的处理迟到数据,设置一个定时器,在定时器触发的时间内完成处理逻辑

 

case class OrderEvent( orderId: Long, eventType: String, txId: String, eventTime: Long )

case class ReceiptEvent( txId: String, payChannel: String, eventTime: Long )

object TxMatch {

  val unmatchedPays = new OutputTag[OrderEvent]("unmatchedPays")
  val unmatchedReceipts = new OutputTag[ReceiptEvent]("unmatchedReceipts")

  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1)
    env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime)

    val orderEventStream = env.readTextFile("YOUR_PATH\\resources\\OrderLog.csv")
.map( data => {
val dataArray = data.split(",")
OrderEvent(dataArray(0).toLong, dataArray(1

你可能感兴趣的:(用Flink实现的一个实时订单对账功能, Flink的双流实时对账)