[rules-users] Is there any way to hook-up Drools 4.0 RuleBase (session) to a Drools 5.0 KnowledgeBase (session) ??

Chetan Mahadev mahadev.chetan at gmail.com
Mon Oct 26 16:09:44 EDT 2009


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??

Following is the test i did. ( http://drools.pastebin.com/m7d6c613b)

Can anybody help??

IN MY JAVA CODE

   1. //load up the rulebase
   2.             RuleBase ruleBase = readRule(); // Read and load rules frm
   a packagebuilder()
   3.             StatefulSession rBaseSession =
   ruleBase.newStatefulSession();
   4.             Message message = new Message();
   5.             message.setMessage(  "Hello World" );
   6.             message.setStatus( Message.HELLO );
   7.             rBaseSession.insert( message );
   8.
   9.                 @@//Load KnoweledgeBase
   10.                         KnowledgeBase kbase = loadRuleBase();  // I
   set options for EventProcessing in loadRuleBase()
   11.                         KnowledgeSessionConfiguration conf =
   12.
   KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
   13.                         ((SessionConfiguration) conf).setClockType(
   ClockType.REALTIME_CLOCK );
   14.                         StatefulKnowledgeSession        kbaseSession
   =  kbase.newStatefulKnowledgeSession(conf,null);
   15.
   16.                         rBaseSession.fireAllRules();
   17.



IN MY RULE FILE

   1. rule "Hello World"
   2.         when
   3.                 $m : Message( status == Message.HELLO, message :
   message )
   4.         then
   5.                 System.out.println( message );
   6.                 Message message2 = new Message();
   7.             message2.setMessage(  "Hello World" );
   8.             message2.setStatus( Message.HELLO );
   9.
   10.         WorkingMemoryEntryPoint eventsignaturestream =
   drools.getEntryPoint("EVENT SIGNATURE STREAM") ;  // I Get a NULLPOINTER
   EXCEPTION here
   11.             eventsignaturestream.insert(message2);
   12.
   13. end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091027/2935cfd3/attachment.html 


More information about the rules-users mailing list