I am running into issue of multiple rules matched and getting rule with lowest Salience. This is the Source File.
package HotelAnalyticsLuxuryPromotions
#generated from Decision Table
import com.mmt.analytics.hotel.promotions.drools.HotelPromotionsDroolsPojo;
import com.mmt.analytics.hotel.promotions.drools.HotelPromotionsDroolRules;
#From row number: 11
rule "for Luxury Hotel Promotions_11"
salience 9
when
fact: HotelPromotionsDroolsPojo(
eval(HotelPromotionsDroolRules.checkHotelId(fact,"12345")),
eval(HotelPromotionsDroolRules.checkRsq(fact,"*")),
eval(HotelPromotionsDroolRules.checkValidCheckInCheckOut(fact,"*")),
eval(HotelPromotionsDroolRules.checkLoggedStatus(fact,"*")))
eval(HotelPromotionsDroolRules.checkActiveStatus(fact,"1"))
then
fact.setPackageName("Pack 2");
fact.setRatePlanCode("ABC 2");
fact.setTariffUrl("TariffUrl");
fact.setClickUrl("ClickUrl");
fact.setInclusionText("InclusionText");
end
#From row number: 12
rule "for Luxury Hotel Promotions_12"
salience 10
when
fact: HotelPromotionsDroolsPojo(
eval(HotelPromotionsDroolRules.checkHotelId(fact,"12345")),
eval(HotelPromotionsDroolRules.checkRsq(fact,"*")),
eval(HotelPromotionsDroolRules.checkValidCheckInCheckOut(fact,"*")),
eval(HotelPromotionsDroolRules.checkLoggedStatus(fact,"*")))
eval(HotelPromotionsDroolRules.checkActiveStatus(fact,"1"))
then
fact.setPackageName("Pack 1");
fact.setRatePlanCode("ABC 1");
fact.setTariffUrl("TariffUrl");
fact.setClickUrl("ClickUrl");
fact.setInclusionText("InclusionText");
end
#From row number: 14
rule "for Luxury Hotel Promotions_14"
salience 5
when
fact:HotelPromotionsDroolsPojo(
eval(HotelPromotionsDroolRules.checkHotelId(fact,"12345")),
eval(HotelPromotionsDroolRules.checkRsq(fact,"*")),
eval(HotelPromotionsDroolRules.checkValidCheckInCheckOut(fact,"*")),
eval(HotelPromotionsDroolRules.checkLoggedStatus(fact,"*")))
eval(HotelPromotionsDroolRules.checkActiveStatus(fact,"1"))
then
fact.setPackageName("Pack 3");
fact.setRatePlanCode("ABC 3");
fact.setTariffUrl("TariffUrl");
fact.setClickUrl("ClickUrl");
fact.setInclusionText("InclusionText");
end
I think rule with highest priority must be returned but I am getting the opposite.
Below is the code of rule Engine
StatelessKnowledgeSession kSession = promotionsDroolManager.getStatelessSession();
kSession.execute(droolsPojo);
I am using these Drool Config Properties
promotions.drools.agent.scan.resources=true
promotions.drools.agent.scan.directories=true
promotions.drools.resource.scanner.interval=1800
promotions.drools.agent.monitor.change.set.events=true
promotions.drools.knowledge.agent.name=Promotions_Knowledge_agent
promotions.drools.base.knowledge.agent.change.set.path=promotions.xml
Pls. suggest
You have three rules with identical left hand sides (conditions). If one matches, they all match. If one fires, they all fire. They fire in an order which you control using salience.
The right hand sides (consequences) are very much alike, values in the identical setters differ. If they all fire, the values in the last group of setters are bound to appear in the matched fact.
This is the group of setters in the rule with lowest salience.
Edit 1. Above all: Why are the conditions identical? It doesn't make sense. 2. Esteban's Proposal is an option. 3. If you don't want to fire more than one rule, call fireAllRules(1). 4. Add a constraint testing that one of the fields (e.g. packageName) is still null. You'll need to call modify or update: