<div dir="ltr">Hello,<div><br></div><div style>I have a problem with the banking tutorial number 3, which is part of the examples of drools expert.</div><div style>It simply adds some Numbers as facts, and retracts them in an increasing order.</div>
<div style><br></div><div style>It is very short, therefore I post the whole Code:</div><div style><br></div><div style><br></div><div style>BankingExample3.java</div><div style>_________________________________________________<br>
</div><div style><div>package org.drools.tutorials.banking;</div><div><br></div><div>public class BankingExample3 {</div><div>    public static void main(String[] args) {</div><div>        Number[] numbers = new Number[] {wrap(3), wrap(1), wrap(4), wrap(1), wrap(5)};</div>
<div>        new RuleRunner().runRules( new String[] { &quot;Example3.drl&quot; },</div><div>                                   numbers );</div><div>    }</div><div>    </div><div>    private static Integer wrap(int i) {</div>
<div>        return new Integer(i);</div><div>    }</div><div>}</div><div>_________________________________________________<br></div><div><br></div><div><br></div><div><br></div><div style>Example3.drl:</div><div style>_________________________________________________<br>
</div><div style><div>package org.drools.tutorials.banking</div><div>  </div><div>rule &quot;Rule 01&quot;   </div><div>    when</div><div>        $number : Number()</div><div>        not Number( intValue &lt; $number.intValue )</div>
<div>    then</div><div>        System.out.println(&quot;Number found with value: &quot; + $number.intValue() ); </div><div>        retract( $number );</div><div>end </div><div>_________________________________________________<br>
</div><div><br></div><div><br></div><div style>Output:</div><div style>_________________________________________________<br></div><div style><div>Loading file: Example3.drl</div><div>Inserting fact: 3</div><div>Inserting fact: 1</div>
<div>Inserting fact: 4</div><div>Inserting fact: 1</div><div>Inserting fact: 5</div><div>Number found with value: 1</div><div>Number found with value: 1</div><div>Number found with value: 3</div><div>Number found with value: 4</div>
<div>Number found with value: 5</div><div>_________________________________________________</div><div><br></div><div><br></div></div><div style>that seams absolute logically to me.</div><div style>But now I alter the Numbers in the Java-Part:</div>
<div style> Number[] numbers = new Number[] {wrap(3), wrap(1), wrap(2)};<br></div><div style><br></div><div style>and the output destroys everything I thought I understood:</div><div style><div>Loading file: Example3.drl</div>
<div>Inserting fact: 3</div><div>Inserting fact: 1</div><div>Inserting fact: 2</div><div>Number found with value: 1</div><div>Number found with value: 3</div><div>Number found with value: 2</div></div></div><div style><br>
</div><div style><br></div></div><div style>Can someone  reproduce this behavior?? It seams absolutely strange to me. I would have expected the order 1,2,3. Any explanations?</div><div style><br></div><div style>Thanks in advance for helping me!</div>
<div style><br></div><div style><br></div></div>