0
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.

Esteban Aliverti
  • 6,259
  • 2
  • 19
  • 31
  • Why don't you continue with the other question you've started? You can edit the question and add the code there. – laune Mar 11 '14 at 07:51
  • You'll have to show more of that "main class", how fact objects are created and insert. Show "real" code, not snippets, preferably code that can be compiled and run. – laune Mar 11 '14 at 07:53
  • OK, and where is the "batch"? Or what is "slow"? – laune Mar 11 '14 at 09:33
  • As @laune mentions: "where is the 'batch'?" How you are iterating through items could well be key to the problem. If that rule above is typical, you *should* be able to rip through a million in seconds. – Steve Mar 11 '14 at 11:09
  • The Talend ETL developer cannot "pass the values to Drool rules by using the Setter and getters methods". Please understand that sloppily reported hearsay is not a viable basis for improving things. How does the ETL code communicate with the Java code running the Drools session? Is this one big Java program? Or is Drools running in a separate process? How is this organized? How is the session started? - The main you've posted is a test program and surely not anywhere near your production code. – laune Mar 12 '14 at 15:43

0 Answers0