I'm playing with Drools Fusion 5.1.1 a bit to try and evaluate whether it is
an appropriate tool for a project I'm working on. As part of that, I'm
playing a bit with its event capabilities, but I'm running into a problem
and I'm not sure whether its a bug or something that I'm doing.
I'm trying to write a rule that looks for a series of two events and I want
to preclude another specific type of event from coming between the two. I've
tried a couple of ways of doing this, and am now trying to use a sliding
window with the following rule:
declare Event
@role(event)
@expires(30ms)
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
This is the only rule in my knowledge base. I create a stateful session and
start inserting facts into it. First a "linkdown" event and then a
"linkup"
event with the same "extra" value. I get the following exception when
inserting the second event:
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)
Browsing the mailing list seems to indicate that this means that for some
reason Drools is interpretting one of my facts as of role fact instead of
role event. I'm not sure why this would be event that the only things I'm
inserting are Event objects, which can be seen above to have the role of
event.
Am I doing something wrong here? Is there something wrong with my rule (and
is it going to do what I think its doing)? Or have I encountered a bug with
the sliding window implementation?
Any thoughts or help would be appreciated.
Will
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/unexpected-ClassCastE...
Sent from the Drools - User mailing list archive at
Nabble.com.