I am seeing different behavior whether I insert events directly into session
or into a named entry-point.
The below rule and test is greenbar'ed:
----
rule "How_do_I_correlate_events_arriving_in_2_or_more_streams?"
when
$e : WithdrawalEvent($accountNumber : accountNumber, $amount : amount)
over window:time(30s)
from entry-point "stream"
$f : FraudWarningEvent(accountNumber == $accountNumber) over
window:time(30s)
from entry-point "stream"
then
results.put("accountNumber", $accountNumber);
results.put("amount", $amount);
end
----
def insert(fact) {
session.getWorkingMemoryEntryPoint("stream").insert(fact)
}
@Test
def void How_do_I_correlate_events_arriving_in_2_or_more_streams() {
// Not the same account
insert new WithdrawalEvent(accountNumber: "AAA", amount: 100)
insert new FraudWarningEvent(accountNumber: "BBB")
fireAllRules()
assert results.isEmpty()
// Not within the 30s window
advanceTime 31, SECONDS
insert new FraudWarningEvent(accountNumber: "AAA")
fireAllRules()
assert results.isEmpty()
....
}
----
But if I do not specify a stream in the rules (ie, remove the 'from
entry-point "stream"') and instead insert directly into the session (like
many of the the drools integration do)...
def insert(fact) {
session.insert(fact)
}
...the test fails. It does not matter how far I advance the clock before
inserting the (second) FraudWarningEvent, the rule always fires.
I only found this difference after looking at the integration tests and
seing that I did not need to use a named entry-point for events. Did I
understand incorrectly? (I was looking at
/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_DelayingNot.drl
and its associated java test.)
--
View this message in context:
http://www.nabble.com/Behavioral-differences-between-session.insert%28%29...
Sent from the drools - user mailing list archive at
Nabble.com.