As an aside note. You may want to consider re-working your rules to never use the || condition.
It's not that this is inherently bad, but that the any logical ORs mean that you are actually representing more than one rule within the singular rule. This can make mapping the logic to the rules difficult in the future. -----Original Message----- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of FrankVhh Sent: Wednesday, November 23, 2011 8:05 AM To: rules-users@lists.jboss.org Subject: Re: [rules-users] Multiple Insert and negative rule rule "test2" salience 5 when not ( Event( (system == "anySystem" && catagory == "anyCatagory" ) || (system == "anyHost" && message matches ".*Hello.*"))) then System.out.println(" No strange message :-) "); end Hi, Probably it is because you are using NOT (). The engine will not fire this rule for every event in the WM. Consider changing from not ( Event( system == "any" ) ) to Event( system != "any" ) That will force the engine to execute it for each Event in memory. Regards, Frank annam2011 wrote > > 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-tp3531135p3531203.html Sent from the Drools: User forum mailing list archive at Nabble.com. _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users _______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users