[rules-users] Sequential mode help!

Ross H rossh00 at gmail.com
Fri Dec 4 22:45:16 EST 2009


Try adding another condition that checks policy.params != null in your
customer condition of rule 2

On Sat, Dec 5, 2009 at 7:25 AM, 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20091205/aa3cb054/attachment.html 


More information about the rules-users mailing list