[jboss-jira] [JBoss JIRA] (DROOLS-1347) Explicit expiration of event not effective - regression from 6.4 to 6.5
Matteo Mortari (JIRA)
issues at jboss.org
Fri Oct 28 10:54:00 EDT 2016
[ https://issues.jboss.org/browse/DROOLS-1347?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13313496#comment-13313496 ]
Matteo Mortari commented on DROOLS-1347:
----------------------------------------
Simplified reproducer with assertions, aligned with OP's case:
{code:java}
public class RuleTest {
static final Logger LOG = LoggerFactory.getLogger(RuleTest.class);
@Test
public void test() throws InstantiationException, IllegalAccessException {
KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
Results verifyResults = kContainer.verify();
for (Message m : verifyResults.getMessages()) {
LOG.info("{}", m);
}
LOG.info("Creating kieBase with STREAM option");
KieBaseConfiguration kieBaseConf = kieServices.newKieBaseConfiguration();
kieBaseConf.setOption( EventProcessingOption.STREAM );
KieBase kieBase = kContainer.newKieBase(kieBaseConf);
LOG.info("There should be rules: ");
for ( KiePackage kp : kieBase.getKiePackages() ) {
for (Rule rule : kp.getRules()) {
LOG.info("kp " + kp + " rule " + rule.getName());
}
}
LOG.info("Creating kieSession");
KieSessionConfiguration config = kieServices.newKieSessionConfiguration();
config.setOption( ClockTypeOption.get("pseudo") );
KieSession session = kieBase.newKieSession(config, null);
SessionPseudoClock clock = session.getSessionClock();
session.addEventListener(new DebugRuleRuntimeEventListener() {
@Override
public void objectDeleted(ObjectDeletedEvent event) {
System.out.println(event.getOldObject() + " " + "x");
}
@Override
public void objectInserted(ObjectInsertedEvent event) {
System.out.println("x" + " " + event.getObject());
}
@Override
public void objectUpdated(ObjectUpdatedEvent event) {
System.out.println(event.getOldObject() + " " + event.getObject());
}
});
session.addEventListener(new DefaultAgendaEventListener() {
@Override
public void afterMatchFired(AfterMatchFiredEvent event) {
System.out.println("fired: "+event.getMatch().getRule());
}
});
LOG.info("Populating globals");
List<String> check = new ArrayList<String>();
session.setGlobal("list", check);
LOG.info("Now running data");
System.out.println("---a---");
clock.advanceTime(1000L, TimeUnit.MILLISECONDS);
session.insert( new Character('a') );
session.fireAllRules();
print(session);
assertTrue(check.contains("Rexpected"));
assertFalse(check.contains("Ravoid"));
System.out.println("---b---");
clock.advanceTime(3600000L, TimeUnit.MILLISECONDS);
session.insert( new Character('b') );
session.fireAllRules();
print(session);
assertTrue(check.contains("Rexpected"));
assertFalse(check.contains("Ravoid"));
}
private void print(KieSession session) {
System.out.println("Session facts:");
for ( FactHandle fh : session.getFactHandles() ) {
InternalFactHandle ifh = (InternalFactHandle) fh;
System.out.println(" > "+ifh.getObject()+" ["+ifh.getObjectClassName()+"] FH: "+fh);
}
}
}
{code}
And rules:
{code:java}
package org.drools.DROOLS_1347;
global java.util.List list;
declare Character
@role( event )
@expires( 1s )
end
declare String
@role( event )
@expires( 10m )
end
rule "Rexpected"
when
$t : Character() over window:length(1)
not String()
then
insert("good");
list.add("Rexpected");
end
rule "Ravoid"
when
$t : Character() over window:length(1)
exists String(this before $t)
not String(this coincides $t)
then
insert("bad");
list.add("Ravoid");
end
{code}
> Explicit expiration of event not effective - regression from 6.4 to 6.5
> -----------------------------------------------------------------------
>
> Key: DROOLS-1347
> URL: https://issues.jboss.org/browse/DROOLS-1347
> Project: Drools
> Issue Type: Bug
> Components: core engine
> Affects Versions: 6.5.0.Final
> Reporter: Thibault Daoulas
> Assignee: Matteo Mortari
>
> I just ugraded my project from Drools 6.4.0.Final to 6.5.0.Final and have now quite a few tests on rules that fail, all have in common that they test the expiration of events, where an event that should have been removed from the working memory is still present.
--
This message was sent by Atlassian JIRA
(v7.2.2#72004)
More information about the jboss-jira
mailing list