最近公司打算把drools引入spark Streaming实时计算引擎,测试了一下,还是很好用
对 JavaPairDStream<String, Float> aggregateRecords 执行以下程序,创建drools session,加载配置文件并执行规则,执行后调用ChannAmount的hbaseSave()方法
aggregateRecords.foreachRDD(new VoidFunction<JavaPairRDD<String, Float>>() {
@Override
public void call(JavaPairRDD<String, Float> stringFloatJavaPairRDD) throws Exception {
stringFloatJavaPairRDD.foreach(new VoidFunction<Tuple2<String, Float>>() {
@Override
public void call(Tuple2<String, Float> stringFloatTuple2) throws Exception {
//Droolssession创建ChannAmount
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbui