(reposting to a more appropriate list)
I'm starting to expirament with Drools and Drools Fusion and am running into
some problems using sliding windows. I'm using Drools 5.1.1 with a fairly
simple configuration. I have one rule:
package net.wlauer.DroolsEngine
import net.wlauer.DroolsEngine.Event
import java.util.ArrayList
declare Event
@role(event)
@expires(30s)
end
rule TestWindow
when
$up : Event (type == "linkup", $inf : extra)
$window : ArrayList () from collect (
Event (extra == $inf) over window:length(2))
$down : Event (type == "linkdown", this before $up) from
$window
then
channels["up"].send($up);
end
I expect this rule to fire whenever it sees a "linkup" event immediately
after a "linkdown" event for the same value of extra. (If you can suggest a
better way to write this, I would appreciate it). My sample program simply
inserts four Events, calling fireAllRules once all the inserts have been
completed.
What I'm seeing instead of my expected results is the exception:
Exception in thread "main" java.lang.ClassCastException:
org.drools.common.DefaultFactHandle cannot be cast to
org.drools.common.EventFactHandle
at
org.drools.base.evaluators.BeforeEvaluatorDefinition$BeforeEvaluator.evaluateCachedLeft(BeforeEvaluatorDefinition.java:333)
at
org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110)
at
org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:115)
at
org.drools.common.SingleBetaConstraints.isAllowedCachedLeft(SingleBetaConstraints.java:142)
at
org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274)
at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.propagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:64)
at
org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:662)
at
org.drools.reteoo.AccumulateNode.assertLeftTuple(AccumulateNode.java:181)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:189)
at
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:138)
at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:148)
at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:59)
at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:145)
at
org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450)
at
org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:368)
at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190)
at
org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1174)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1123)
at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:917)
at
org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:251)
at
net.wlauer.DroolsEngine.NonSpringRulesEngine.main(NonSpringRulesEngine.java:71)
From scanning the list, it looks like this implies that a non-event
fact is
being treated as an event-type fact, but I don't see where that could
be
happening. Am I doing something obviously wrong? I've tried marking
ArrayList as an event type, but that didn't change the behavior.
Any insight you can give me would be appreciated.
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/sliding-window-proble...
Sent from the Drools - User mailing list archive at
Nabble.com.