Flink實時對賬 雙流join

2022-07-15 16:42:14 字數 1117 閱讀 3774

import org.apache.flink.api.common.state.valuestatedescriptor

import org.apache.flink.api.scala.typeutils.types

import org.apache.flink.streaming.api.timecharacteristic

import org.apache.flink.streaming.api.functions.co.coprocessfunction

import org.apache.flink.streaming.api.scala.

import org.apache.flink.util.collector

/** * 場景:實時對賬

*/object twostreamjoin

//泛型:第一條流 第二條流 輸出

class machfuction extends coprocessfunction[orderevent, payevent, string] else

}//處理支付流的資料

override def processelement2(pay: payevent, ctx: coprocessfunction[orderevent, payevent, string]#context, out: collector[string]): unit = else

}override def ontimer(timestamp: long, ctx: coprocessfunction[orderevent, payevent, string]#ontimercontext, out: collector[string]): unit =

if (orderstate.value() != null) }}

}

對賬成功---> 訂單id為order_1的訂單對賬成功

對賬成功---> 訂單id為order_2的訂單對賬成功

訂單未到-----> 訂單是order_3對賬失敗

支付未到-----> 訂單是order_5對賬失敗

支付未到-----> 訂單是order_6對賬失敗

Flink 實現 雙流Join

將五分鐘之內的訂單資訊和支付資訊進行對賬,對不上的發出警告 import org.apache.flink.api.common.state.import org.apache.flink.api.scala.typeutils.types import org.apache.flink.strea...

Flink 雙流合併之connect Demo2

1 主類 package towstream program demo description author yang create 2020 12 31 11 39 import org.apache.flink.api.common.state.import org.apache.flink.a...

Flink 雙流合併之connect Demo1

1 主類 package towstream program demo description author yang create 2020 12 31 11 39 import org.apache.flink.api.common.state.import org.apache.flink.a...