8

We are using Drools v6.3.4 - but tested that the same issue is happening in v7.3.0 as well. When we write a rule where the rule is 27000 characters long or more, we get "Unable to Analyse Expression" error

rule "StoreRule"

    when
        (s: Store.StoreItems(storeitemname in ("STORE0000001","STORE0000002"....really long list)))
    then
        System.out.println("Discount!");
end

We have a workaround which is to split the rule up like this -

rule "StoreRule"

    when
        (s: Store.StoreItems(storeitemname in (<List 1>))) ||
        (s: Store.StoreItems(storeitemname in (<List 2>))) ||....and so on
    then
        System.out.println("Discount!");
end

What is the underlying reason for the error we are getting with a single long list? Is there a better way to handle such rules other than the workaround specified above?

When we are having large rule , we are getting the following error.

enter image description here

Vinod
  • 596
  • 2
  • 10
  • 28
  • as I understand that you are trying to check whether particular SKU list is available in store or not or vice versa. instead of checking it in drools why you are not using DB for same. – Devratna May 29 '18 at 11:03
  • You can use hashmap to check whether that itemname is there in StoreItems. The hashmap should have key as the itemname. Try using and hashmap and check. For the InvalidRulePackage Exception solution can you add an example rule and the POJO object members? – Prog_G May 31 '18 at 05:28
  • @Devratna - we are using Drools for a lot of other types of rules that work perfectly. Hence we were trying to look at a solution around the current drools framework that we have. – Srividya Sriram May 31 '18 at 05:41
  • You're definitely not using Drools 6.3.4 for two reasons. First of all, there _is no_ 6.3.4. There's a 6.3.0.Final and a 6.4.0.Final. Furthermore, `org.drools.core.rule.Package` didn't exist from 6.1 onwards. – Roddy of the Frozen Peas Feb 22 '20 at 22:08

1 Answers1

-1

Make sure one storeitemname can't be part of other storeitemname

rule "StoreRule"

    when
        (s: Store.StoreItems("STORE0000001|STORE0000002|really long list" contains storeitemname))
    then
        System.out.println("Discount!");
end
Mike
  • 20,010
  • 25
  • 97
  • 140