將五分鐘之內的訂單資訊和支付資訊進行對賬,對不上的發出警告
importorg.apache.flink.api.common.state.
import
org.apache.flink.api.scala.typeutils.types
import
org.apache.flink.streaming.api.timecharacteristic
import
org.apache.flink.streaming.api.functions.co.keyedcoprocessfunction
import
org.apache.flink.streaming.api.scala._
import
org.apache.flink.util.collector
/*** $content
* *
@author
yangxu
* @date 2020/6/20 14:36
* @version
1.0
*/object twostreamjoindemo
//進入同一條流中的資料肯定是同乙個key,即orderid
class matchfunction extends
keyedcoprocessfunction[string, orderevent, payevent, string]
else
}override def processelement2(value: _root_.project.twostreamjoindemo.payevent, ctx: _root_.org.apache.flink.streaming.api.functions.co.keyedcoprocessfunction[_root_.scala.predef.string, _root_.project.twostreamjoindemo.orderevent, _root_.project.twostreamjoindemo.payevent, _root_.scala.predef.string]#context, out: _root_.org.apache.flink.util.collector[_root_.scala.predef.string]): unit =
else
}override def ontimer(timestamp: long, ctx: keyedcoprocessfunction[string, orderevent, payevent, string]#ontimercontext, out: collector[string]): unit = 的兩條流沒有對賬成功!")
orderstate.clear()
}if (paystate.value() != null
) 的兩條流沒有對賬成功!")
paystate.clear()}}
}}
Flink實時對賬 雙流join
import org.apache.flink.api.common.state.valuestatedescriptor import org.apache.flink.api.scala.typeutils.types import org.apache.flink.streaming.api....
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...