To accomplish this is largely a “renaming” operation.  They are syntactically the same.  I did a similar thing a few months ago and it mostly involved renaming everything from RuleXXX to KnowledgeXXX.

 

 


From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Chetan Mahadev
Sent: Monday, October 26, 2009 4:10 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Is there any way to hook-up Drools 4.0 RuleBase(session) to a Drools 5.0 KnowledgeBase (session) ??

 

 

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
  1.             RuleBase ruleBase = readRule(); // Read and load rules frm a packagebuilder()
  1.             StatefulSession rBaseSession = ruleBase.newStatefulSession();
  1.             Message message = new Message();
  1.             message.setMessage(  "Hello World" );
  1.             message.setStatus( Message.HELLO );
  1.             rBaseSession.insert( message );
  1.              
  1.                 @@//Load KnoweledgeBase              
  1.                         KnowledgeBase kbase = loadRuleBase();  // I set options for EventProcessing in loadRuleBase()
  1.                         KnowledgeSessionConfiguration conf =
  1.                         KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
  1.                         ((SessionConfiguration) conf).setClockType( ClockType.REALTIME_CLOCK );
  1.                         StatefulKnowledgeSession        kbaseSession =  kbase.newStatefulKnowledgeSession(conf,null);
  1.                                                
  1.                         rBaseSession.fireAllRules();  
  1.  

 

IN MY RULE FILE

  1. rule "Hello World"
  1.         when
  1.                 $m : Message( status == Message.HELLO, message : message )
  1.         then
  1.                 System.out.println( message );
  1.                 Message message2 = new Message();
  1.             message2.setMessage(  "Hello World" );
  1.             message2.setStatus( Message.HELLO );
  1.  
  1.         WorkingMemoryEntryPoint eventsignaturestream = drools.getEntryPoint("EVENT SIGNATURE STREAM") ;  // I Get a NULLPOINTER EXCEPTION here
  1.             eventsignaturestream.insert(message2);
  1.  
  1. end