Hi ,
We have been using drools 4.0 in our application. All the rules are loaded using RuleBase and PackageBuilder.
The application is pretty old, and has got lot of work into it.
Now we want to use Drools 5.0 CEP (Fusion) along with the old rules (based on drools 4.0).
But the problem , is, how can we hook-up the old "RuleBase" based sessions with the "KnowledgeBase" sessions of Drools 5.0??
The use case is:
1.Fact enters the system ( asserted using Rulebase), is enriched by rules (Based on Drools 4.0)
2.The same fact will be treated as EVENT (for CEP), for further correlation of Events (facts) using KnowledgeBase as proposed i Drools 5.0.
I am facing difficulty in hooking up the two sessions. Is there an way??
Can anybody help??
IN MY JAVA CODE
-
//load up the rulebase
-
RuleBase ruleBase = readRule(); // Read and load rules frm a packagebuilder()
-
StatefulSession rBaseSession = ruleBase.newStatefulSession();
-
Message message = new Message();
-
message.setMessage( "Hello World" );
-
message.setStatus( Message.HELLO );
-
rBaseSession.insert( message );
-
-
@@//Load KnoweledgeBase
-
KnowledgeBase kbase = loadRuleBase(); // I set options for EventProcessing in loadRuleBase()
-
KnowledgeSessionConfiguration conf =
-
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
-
((SessionConfiguration) conf).setClockType( ClockType.REALTIME_CLOCK );
-
StatefulKnowledgeSession kbaseSession = kbase.newStatefulKnowledgeSession(conf,null);
-
-
rBaseSession.fireAllRules();
-
IN MY RULE FILE
-
rule "Hello World"
-
when
-
$m : Message( status == Message.HELLO, message : message )
-
then
-
System.out.println( message );
-
Message message2 = new Message();
-
message2.setMessage( "Hello World" );
-
message2.setStatus( Message.HELLO );
-
-
WorkingMemoryEntryPoint eventsignaturestream = drools.getEntryPoint("EVENT SIGNATURE STREAM") ; // I Get a NULLPOINTER EXCEPTION here
-
eventsignaturestream.insert(message2);
-
-
end