<div>Hi,</div><div><br></div><div>Thank you for your reply. I will use the Knowledge API going forward.</div><div><br></div><div>Can you please explain what you mean by &quot;deviate from the constraint syntax as defined with 5.1.1&quot;? What&#39;s an example of 5.1.1 syntax, and what&#39;s an example of a deviation?</div>
<div><br></div><div>-Matt</div><br><div class="gmail_quote">On Tue, Sep 27, 2011 at 5:12 AM, laune [via Drools] <span dir="ltr">&lt;<a href="/user/SendEmail.jtp?type=node&node=3376645&i=0" target="_top" rel="nofollow" link="external">[hidden email]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

        Please use the new &quot;knowledge&quot; API for compiling and building a knowledge (not: rule) base.<br><br>This bug has been fixed for 5.3.0. It is one of several that may occur when you use 5.2.0 and deviate from the constraint syntax as defined with 5.1.1.<br>

<br>-W<br><br><br><div class="gmail_quote">On 26 September 2011 22:51, matvey1414 <span dir="ltr">&lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=3372058&amp;i=0" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt;</span> wrote:<br>
<blockquote style="border-left:2px solid #CCCCCC;padding:0 1em" class="gmail_quote">
Hi,<br>
<br>
I am working with Drools to implement a high-profile rules-engine. I have<br>
two rules defined. Clearly, only the first should fire, but both do. Here is<br>
my DRL:<br>
<br>
<br>
package com.sample<br>
<br>
import com.sample.DroolsTest.Request;<br>
<br>
rule &quot;ExpensiveCanonShopper0&quot;<br>
when<br>
        Request( attributeMap[&quot;camera0&quot;] == &quot;canon&quot; &amp;&amp;<br>
attributeMap[&quot;price0&quot;] &gt;= 500 )<br>
then<br>
        System.out.println(&quot;ExpensiveCanonShopper0&quot;);<br>
end<br>
<br>
rule &quot;ExpensiveCanonShopper1&quot;<br>
when<br>
        Request( attributeMap[&quot;camera1&quot;] == &quot;canon&quot; &amp;&amp;<br>
attributeMap[&quot;price1&quot;] &gt;= 500 )<br>
then<br>
        System.out.println(&quot;ExpensiveCanonShopper1&quot;);<br>
end<br>
<br>
And the Java class to execute it:<br>
<br>
public class DroolsTest {<br>
<br>
        @SuppressWarnings({ &quot;rawtypes&quot;, &quot;unchecked&quot; })<br>
        public static final void main(String[] args) {<br>
                try {<br>
                        //Loading the Rules<br>
                        System.out.println(&quot;Loading rules&quot;);<br>
                        RuleBase ruleBase = readRule();<br>
                        StatelessSession workingMemory =<br>
ruleBase.newStatelessSession();<br>
<br>
                        System.out.println(&quot;Firing rules&quot;);<br>
<br>
                        Map map = new HashMap();<br>
                        map.put(&quot;camera0&quot;, &quot;canon&quot;);<br>
                        map.put(&quot;price0&quot;, 600);<br>
<br>
                        Request request = new Request();<br>
                        request.setAttributeMap(map);<br>
                        workingMemory.execute(request);<br>
<br>
                } catch (Throwable t) {<br>
                        t.printStackTrace();<br>
                }<br>
        }<br>
<br>
        /**<br>
         * Please note that this is the “low level” rule assembly API.<br>
         */<br>
        private static RuleBase readRule() throws Exception {<br>
                //read in the source<br>
                Reader source = new FileReader(new File(&quot;drl&quot;,<br>
&quot;Generated.drl&quot;));<br>
<br>
                //optionally read in the DSL (if you are using it).<br>
                //Reader dsl = new InputStreamReader(<br>
DroolsTest.class.getResourceAsStream( “/mylang.dsl” ) );<br>
<br>
                //Use package builder to build up a rule package.<br>
                //An alternative lower level class called “DrlParser” can<br>
also be used…<br>
<br>
                PackageBuilder builder = new PackageBuilder();<br>
<br>
                //this wil parse and compile in one step<br>
                //NOTE: There are 2 methods here, the one argument one is<br>
for normal DRL.<br>
                builder.addPackageFromDrl( source );<br>
                if (builder.hasErrors()) {<br>
                        PackageBuilderErrors errors = builder.getErrors();<br>
                        throw new RuntimeException(&quot;Error adding package to<br>
builder: &quot; + errors.toString());<br>
                }<br>
<br>
                //Use the following instead of above if you are using a DSL:<br>
                //builder.addPackageFromDrl( source, dsl );<br>
<br>
                //get the compiled package (which is serializable)<br>
                Package pkg = builder.getPackage();<br>
<br>
                //add the package to a rulebase (deploy the rule package).<br>
                RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br>
                ruleBase.addPackage( pkg );<br>
                return ruleBase;<br>
        }<br>
<br>
        public static class Request {<br>
                private Map attributeMap;<br>
<br>
                public Map getAttributeMap() {<br>
                        return attributeMap;<br>
                }<br>
<br>
                public void setAttributeMap(Map attributeMap) {<br>
                        this.attributeMap = attributeMap;<br>
                }<br>
        }<br>
}<br>
<br>
The output is this, meaning both rules fired:<br>
Loading rules<br>
Firing rules<br>
ExpensiveCanonShopper1<br>
ExpensiveCanonShopper0<br>
<br>
I have two questions:<br>
<br>
1. Is this a bug, or am I doing something wrong? Only<br>
&quot;ExpensiveCanonShopper0&quot; should fire.<br>
<br>
2. I am pretty sure this is somehow related to the fact that I&#39;m using Map<br>
attributes, and not POJO to get &quot;price0&quot; and &quot;camera0&quot;. My issue is that I<br>
won&#39;t know the parameters in advance (they are coming in a URL), so I can&#39;t<br>
pre-declare them, and thus need something dynamic like a Map. Is this how<br>
Drools is intended to be used? The documentation appears very POJO-centric.<br>
<br>
I am using Drools 5.2<br>
<br>
Thank you!<br>
-Matt<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3370653.html" rel="nofollow" link="external" target="_blank">http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3370653.html</a><br>


Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="http://user/SendEmail.jtp?type=node&amp;node=3372058&amp;i=1" rel="nofollow" link="external" target="_blank">[hidden email]</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>
<br>_______________________________________________
<br>rules-users mailing list
<br><a href="http://user/SendEmail.jtp?type=node&amp;node=3372058&amp;i=2" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" link="external" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
        
        <br>
        <br>
        <hr noshade size="1" color="#cccccc">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3372058.html" target="_blank" rel="nofollow" link="external">http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3372058.html</a>
        </div>
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em">
                
                To unsubscribe from Unsatisfied rule fires - Drools bug?, <a href="" target="_blank" rel="nofollow" link="external">click here</a>.
        </div></blockquote></div><br><br clear="all"><div><br></div>-- <br><a href="http://www.calcmachine.com" target="_top" rel="nofollow" link="external">www.calcmachine.com</a> - easy online calculator.<br>

        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://drools.46999.n3.nabble.com/Unsatisfied-rule-fires-Drools-bug-tp3370653p3376645.html">Re: [rules-users] Unsatisfied rule fires - Drools bug?</a><br/>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html">Drools: User forum mailing list archive</a> at Nabble.com.<br/>