[rules-users] Event consuming policy

Edson Tirelli ed.tirelli at gmail.com
Mon Dec 14 16:20:02 EST 2009


   You are not using the configuration you created... you need to pass it as
a parameter to the factory:


            KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
            config.setOption(EventProcessingOption.STREAM);

            KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(
config );
            kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());


   As it is now, your are using CLOUD mode. Since you are not timestamping
events, the engine is using the system clock and your application should not
rely on the matching order. If you need a specific matching order, you need
to use one of the conflict resolution strategies (like salience).

   Edson

2009/12/14 Khalil Hafsi <hafsi at fzi.de>

>  Hi Edson,
>
> I am running in stream mode , I used this function
>
> config.setOption(EventProcessingOption.STREAM);
>
> to enable it.
>
> About the clock and time stamping I am not using anything special , this is
> the initiation part of my main :
>
>
>             KnowledgeBuilder kbuilder =
> KnowledgeBuilderFactory.newKnowledgeBuilder();
>             kbuilder.add(ResourceFactory.newClassPathResource("pol.drl"),
> ResourceType.DRL);
>             if ( kbuilder.hasErrors() ) {
>                 System.err.println( kbuilder.getErrors().toString() );
>             }
>             KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
>             kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
>
>
>             KnowledgeBaseConfiguration config =
> KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
>             config.setOption(EventProcessingOption.STREAM);
>             StatefulKnowledgeSession ksession =
> kbase.newStatefulKnowledgeSession();
>             WorkingMemoryEntryPoint mainS =
> ksession.getWorkingMemoryEntryPoint( "mainS" );
>
> Thank you,
> Khalil Hafsi
>
> Edson Tirelli wrote:
>
>
>    Are you running in STREAM or CLOUD mode? What clock are you using? Are
> you timestamping the events or are you using the clock to timestamp them?
>
>    Edson
>
> 2009/12/14 Khalil Hafsi <hafsi at fzi.de>
>
>> Hi Guys,
>>
>> I was working lately with drools fusion, we wanted to know what event
>> consumption policy was implemented.
>> We made the following simple rule :
>>
>> rule a
>>
>>    when
>>        $c1 : Event(symbol == 1 , $l1 :load) from entry-point "mainS"
>>         and
>>        $c2 : Event(this after $c1,symbol == 2,$l2 :load) from
>> entry-point "mainS"
>>
>>    then
>>        System.out.println("event1 "+$l1+" event2 "+$l2);
>>
>> end
>>
>> The event class has just symbol : int and load : int , load is used to
>> differentiate between different events that have the same symbol.
>>
>> and then we declared the following events into the stream using the
>> constructor Event(symbol,load): with mainS being a WorkingMemoryEntrypoint
>>
>>            mainS.insert(new Event(1,10.0));
>>            mainS.insert((new Event(1,20.0)));
>>            mainS.insert((new Event(1,30.0)));
>>            mainS.insert(new Event(2,80.0));
>>            mainS.insert(new Event(2,90.0));
>>
>>
>> We have the following output :
>>
>>          event1 30.0 event2 90.0
>>          event1 20.0 event2 90.0
>>          event1 10.0 event2 90.0
>>          event1 10.0 event2 80.0
>>
>> So what is exactly the consumption policy used in DROOLS ? It seems that
>> is unrestricted for event 90.0 and chronological for event 80 .
>>
>> We have tested different situations and order of events and we always
>> came to the conclusion that for the first $c2 the policy is
>> chronological and for all the other $c2's it is unrestricted.
>>
>> Thank you for you time.
>> Khalil
>>
>> _______________________________________________
>>
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091214/70c8b060/attachment.html 


More information about the rules-users mailing list