[rules-users] Multiple Insert and negative rule
annam2011
diebanane88 at gmx.de
Wed Nov 23 10:47:10 EST 2011
Hello,
I'm a newbie to drools.
I would like to know why i get the following output on the console :
Test Message found!!
No strange message :-)
Test Message found!!
Test Message found!!
NotifyEngineTest.java creates 10 events. Rule "test2" should be activated
with every event,
so that the output should look like this:
Test Message found!!
No strange message :-)
Test Message found!!
No strange message :-)
Test Message found!!
No strange message :-)
Could somebody help me with this ?
I appriciate your help
Thanks in advance,
Anna
// NotifyEngineTest.java//
for (int i = 0; i < 10; i++){
Event e = new Event();
e.setId("ID"+Math.random());
e.setTimestamp(new Date());
e.setCatagory("TEST");
e.setMessage( i + " Test");
e.setSystem("localhost");
ruleEngine.insert(e);
_____________________________________________________________________
// RuleEngine.java//
public void insert(Event e) throws RuleEngineException {
FactHandle factHandle = ksession.insert(e);
int numberOfRules = ksession.fireAllRules();
logger.debug("Rules fired: "+numberOfRules);
}
______________________________________________________________________
// Notify.drl//
rule "test"
salience 10
when
$r: Event(message matches ".*Test.*")
then
System.out.println("Test Message found!! "+ $r);
end
rule "test2"
salience 5
when
not ( Event( (system == "anySystem" && catagory == "anyCatagory" ) ||
(system == "anyHost" && message matches ".*Hello.*")))
then
System.out.println(" No strange message :-) ");
end
____________________________________________________________________
--
View this message in context: http://drools.46999.n3.nabble.com/Multiple-Insert-and-negative-rule-tp3531135p3531135.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list