rule "ReportableRule1"
dialect "mvel"
when
rp : repoio( country == null )
then
rp.setOrigBuySellFlag( "E" );
System.out.println("This is the exception of rule1");
end.
Hi Steve, This is the sample rule that we have created. Other rules are also almost of same kind.
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("ksession-rules");
My main class is having this code as we are using KIE API.Can there be any other way to design rules for fast processing.next is only set and get. This is my main class where i have set and get.
public static final void main(String[] args) {
try {
// load up the knowledge base
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("ksession-rules");
// go !
HRFReportableVO rp=new HRFReportableVO();
rp.setDefaultSystemFlag("true");
rp.setDefaultCntrPartyFlag("true");
rp.setSecurity("NL0010060257");
rp.setTradeType("SALES_TRADER");
rp.setTradeSubType("ALLOC_BLOCK");
rp.setBoClientAcctId("fsd");
rp.setSubtypec(null);
rp.setSysClientAccId("DROPCTL2");
rp.checkFutureDate("2013-12-27", "2012-01-03");
rp.setCountryOfInc("DEU");
rp.setTransactiontype("S");
String abc="-50.90";
double amount = Double.parseDouble(abc);
rp.setInvalidQuantity(amount);
rp.setActid("xsd");
rp.setDealerID("SBILGB2LXXX");
rp.setMonth(0);
rp.setYear(2012);
rp.setChecktrade(1);
rp.setCounterPart(14);
rp.setCountry("AFG");
rp.setSystem(14);
rp.matchDate("yyyy-MM-dd", "12-12-2013");
rp.checkDate("2013-12-12");
rp.setTypc("GOVT");
rp.setInsttypc("SEC");
//rp.setTradeDate(null);
//rp.setTradeDate(new Date(System.currentTimeMillis()));
rp.setOrigBuySellFlag("A");
rp.setLglEntyCd("2");
rp.setIscrcy("EUR");
rp.setIscntry("GBR");
rp.setGermany_reportable_flag("Y");
kSession.insert(rp);
kSession.fireAllRules();
System.out.println(rp.getExceptionDescription());
System.out.println(rp.getFlag());
} catch (Throwable t) {
t.printStackTrace();
}
}
We have integrated the Drool rules with Talend ETL. Talend ETL developer says that he has passed the values to Drool rules by using the Setter and getters method similar to the code that I have shown in the main class. The problem here is our manager says that drool takes one record compares it with the rules, then gives result of that record. He is asking me to change the code in such a way that Drool takes more records and in lot gives the result so that processing becomes fast.