[rules-users] Drools : 2 identical calls to the same knowledgeBase don't give the same result… why?

antoine antoine.stalin at gmail.com
Mon Feb 10 12:06:40 EST 2014


Hello,

I've faced some weird result using Drools 5.5.0.Final, and I would like to
know if I am doing something wrong ?

I am using drools to process some user rules (the Excel way). If I call the
rules with the exact same data at different time in the process, I don't get
the same result. (I am using a StateLessSession)

After digging a bit more, I managed to extract a very simple maven-based
unit-test to reproduce the problem. (the archive can be downloaded here : 
http://www.filedropper.com/using-drools
<http://www.filedropper.com/using-drools>   )

In fact, I call many times to execute the same rule, and after the 23rd
times I don't get the same expected result :
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:status-rules-config.xml" })
public class StatusRuleTest {
    @Autowired StatusRule ruleRunner;

    @Test public void do_not_work_at_25th_call() throws Exception {
        for(int i = 0 ; i < 35 ; i++){
            MyFact fact = new MyFact();
            assertThat(fact.getStatus()).isEqualTo("NONE");

            ruleRunner.defineStatus(fact);

            assertThat(fact.getStatus()).isEqualTo("DONE");
        }
    }
}

with rule definition as :
public class StatusRuleImpl implements StatusRule {

    @Setter private StatelessKnowledgeSession ksessionStatus;

    @Override
    public void defineStatus(MyFact myFact) {
        ksessionStatus.addEventListener(new DebugAgendaEventListener() );
        ksessionStatus.addEventListener(new
DebugWorkingMemoryEventListener());
        ksessionStatus.execute(myFact);
    }
}

It uses a statelessSession, with sequential mode and ACTIVATION-GROUP
column.
I also posted more details and more logs here : 
http://stackoverflow.com/questions/21585666/drools-2-identical-calls-to-the-same-knowledgebase-dont-give-the-same-result
<http://stackoverflow.com/questions/21585666/drools-2-identical-calls-to-the-same-knowledgebase-dont-give-the-same-result>  

>From what I checked, it might be coming from the negative BigDecimal (If I
change it to 10 in both of the code and the Excel, it seems to work)

If someone has an Idea, I will be pleased to read it !
Thanks in advance,

Antoine



--
View this message in context: http://drools.46999.n3.nabble.com/Drools-2-identical-calls-to-the-same-knowledgeBase-don-t-give-the-same-result-why-tp4028038.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list