[rules-users] Sequential mode help!

Wolfgang Laun wolfgang.laun at gmail.com
Sat Dec 5 01:28:31 EST 2009


I don't see the initialisation of fields modelGroup and region in the Params
fact. They aren't int, but Integer, and so not zero by default.
-W

On Fri, Dec 4, 2009 at 10:25 PM, Torfox <bartosz.jankiewicz at gmail.com> wrote:
>
> Hi,
>
> I couldn't find an solution to a problem I'm struggling with for many hours.
>
> Generally I'm trying to implement sequential mode rules. I have applied
> salience parameters to order the rules, but the engine is not executing
> these rules in that order.
>
> I use drools 5.0.1 in sequential mode, stateless session.
>
> As far as I understand the documentation, in this mode the rules should be
> fired in accordance to the salience attribute.
>
>        RuleBaseConfiguration conf = new RuleBaseConfiguration();
>        conf.setSequential( true);
>        KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(
> conf);
>        session = knowledgeBase.newStatelessKnowledgeSession();
>        ...
>
> The following code snapshot proves that the execution order totally ignores
> salience - "rule2" is fired prior to the "rule1" causing
> NullPointerException since the Params is initiated in "rule1".
>
> package com.kaguar.pzu;
>
> import java.util.*;
> import com.kaguar.entities.*;
>
> global java.util.Set output;
>
> declare Params
>    version      : String
>    modelGroup  : Integer
>    region       : Integer
> end
>
> rule "rule1"
>        salience 1000
>        when
>                $c: Customer()
>        then
>                Params p = new Params();
>                p.setVersion( "1.0");
>                insert( p);
>                output.add( p);
>                $c.getPolicy().setParams( p);
>                System.out.println( "Initiation complete");
> end
>
>
> rule "rule2"
>        salience 0
>        when
>                exists Params()
>                $c: Customer( vehicle.age == 2, policy.params.modelGroup ==
> 1, policy.params.region == 1)
>        then
>                System.out.println( "test");
> end
>
> Please help!!!
>
> --
> View this message in context: http://n3.nabble.com/Sequential-mode-help-tp68511p68511.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>




More information about the rules-users mailing list