Guided Decision Table running in endless loop

267 views
Skip to first unread message

Zeng xijin

unread,
Mar 30, 2017, 7:28:31 AM3/30/17
to Drools Usage
env info:
wildfly-10.1.0.Final.zip
kie-server-6.5.0.Final-ee7.war
kie-drools-wb-6.5.0.Final-wildfly10.war
CentOS 6.6-64bit

I attached the whole source project downloaded from workbench that I made some  Guided Decision Table test.

CPU increase to over 100%


and the POSTMAN request is stuck


{
"lookup": "globalTestStateless",
"commands": [

{
"insert": {
"return-object": true,
"out-identifier": "UserInfo",
"object": {
"com.qf.globaltest.LoanAppInfo": {
"age":1,
"income":2000
}
}
}
},
{
"set-global": {
"identifier": "myMap",
"out-identifier": "output",
"object": {
"java.util.HashMap": {
}
}
}
},
{
"fire-all-rules": ""
},
{
"get-global":
{
  "identifier":"myMap","out-identifier":"helperOutput"
}
},
{
"get-objects":{
                "out-identifier":"myobject"
            }
}
]
}




in the Guided Decision Table ,view the Source tab, and the no-loop is set to be ture, why the rules running  in endless loop?


anyone meet this issue before or is there something I missing?

thanks for any help...









quark-globalTest.zip

Zeng xijin

unread,
Mar 30, 2017, 7:37:40 AM3/30/17
to Drools Usage
when I change the post json:

from

{
"fire-all-rules": ""
}

to

{
"fire-all-rules": {"max":10,"out-identifier":"firedActivations"}
}

it can return results as expected:

{
  "type": "SUCCESS",
  "msg": "Container globalTest1.5 successfully called.",
  "result": {
    "execution-results": {
      "results": [
        {
          "key": "output",
          "value": {
            "A001": "reject"
          }
        },
        {
          "key": "firedActivations",
          "value": 10
        },
        {
          "key": "myobject",
          "value": [
            {
              "com.qf.globaltest.LoanAppInfo": {
                "name": null,
                "age": 1,
                "income": 2000,
                "buffer": {
                  "A1002": 200,
                  "A1001": "REJECT"
                }
              }
            }
          ]
        },
        {
          "key": "UserInfo",
          "value": {
            "com.qf.globaltest.LoanAppInfo": {
              "name": null,
              "age": 1,
              "income": 2000,
              "buffer": {
                "A1002": 200,
                "A1001": "REJECT"
              }
            }
          }
        },
        {
          "key": "helperOutput",
          "value": {
            "A001": "reject"
          }
        }
      ],
      "facts": [
        {
          "key": "UserInfo",
          "value": {
            "org.drools.core.common.DefaultFactHandle": {
              "external-form": "0:1:1374304991:1374304991:6:DEFAULT:NON_TRAIT:com.qf.globaltest.LoanAppInfo"
            }
          }
        }
      ]
    }
  }
}

is not adding the {"max":10,"out-identifier":"firedActivations"} limit, it still  running in endless loop

Michael Anstis

unread,
Mar 30, 2017, 9:23:56 AM3/30/17
to Drools Usage
You're updating $a and notifying the engine of the change in the THEN; which then leads to re-evaluation of the WHEN which remains true; so the THEN executes.. which.. and so on.

Either add a constraint to your WHEN to prevent recursion or look into "property reactivity" in the Drools User Guide (which will be enabled by default in 7.x)

For example: $a : LoanAppInfo( whatEverIsUpdatedByUpdateBuffer == null, income < 5000)

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/2f26ee07-349e-4da9-8585-d93d7ecfe55d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zeng xijin

unread,
Mar 31, 2017, 2:10:06 AM3/31/17
to Drools Usage
hi,mike

I removed the update($a)  in Guided Decision Table, it works fine and does not cause infinite-loop.

I have other question:


I copy the Guided Decision Table auto generate drl source code to pure DRL writting field, and add the update($a) in it
package com.qf.globaltest;

rule "custom ageCheck"
no-loop true
dialect "java"
when
$a : LoanAppInfo( age < 25 )
then
$a.updateBuffer( "customAgeCheck", "REJECT" );
update($a);
end



rebuild the project and deploy to kie-server container , post fire-all-rules request without "max" parameter, it works fine and doesn't cause infinite-loop.
{
"fire-all-rules": ""
}

so why update($a) cmd works different between Guided Decision Table and pure DRL code?
is there something special about Guided Decision Table about update command?


在 2017年3月30日星期四 UTC+8下午9:23:56,Michael Anstis写道:

Michael Anstis

unread,
Mar 31, 2017, 6:05:22 AM3/31/17
to Drools Usage
No, there is nothing special about decision tables "update" command.

Decision Tables are simply a convenience for Users to more easily produce DRL.

Are you sure kie-server is not running with an old KJAR without the update?

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.

Zeng xijin

unread,
Mar 31, 2017, 9:42:01 PM3/31/17
to Drools Usage
absolutely running the new KJAR because I got the new result back from the new rule adding by pure DRL writting

POST:

{
"lookup": "globalTestStateless",
"commands": [

{
"insert": {
"return-object": true,
"out-identifier": "UserInfo",
"object": {
"com.qf.globaltest.LoanAppInfo": {
"age":1,
"income":2000
}
}
}
},
{
"set-global": {
"identifier": "myMap",
"out-identifier": "output",
"object": {
"java.util.HashMap": {
}
}
}
},
{
"fire-all-rules": ""
},
{
"get-global":
{
  "identifier":"myMap","out-identifier":"helperOutput"
}
},
{
"get-objects":{
                "out-identifier":"myobject"
            }
}
]
}

RESPONSE:(notice the red bellow)
{
  "type": "SUCCESS",
  "msg": "Container globalTest1.7 successfully called.",
  "result": {
    "execution-results": {
      "results": [
        {
          "key": "output",
          "value": {
            "A001": "reject"
          }
        },
        {
          "key": "",
          "value": 4
        },
        {
          "key": "myobject",
          "value": [
            {
              "com.qf.globaltest.LoanAppInfo": {
                "name": null,
                "age": 1,
                "income": 2000,
                "buffer": {
                  "customAgeCheck": "REJECT",
                  "A1002": 200,
                  "A1001": "REJECT"
                }
              }
            }
          ]
        },
        {
          "key": "UserInfo",
          "value": {
            "com.qf.globaltest.LoanAppInfo": {
              "name": null,
              "age": 1,
              "income": 2000,
              "buffer": {
                "customAgeCheck": "REJECT",
                "A1002": 200,
                "A1001": "REJECT"
              }
            }
          }
        },
        {
          "key": "helperOutput",
          "value": {
            "A001": "reject"
          }
        }
      ],
      "facts": [
        {
          "key": "UserInfo",
          "value": {
            "org.drools.core.common.DefaultFactHandle": {
              "external-form": "0:1:176379641:176379641:2:DEFAULT:NON_TRAIT:com.qf.globaltest.LoanAppInfo"
            }
          }
        }
      ]
    }
  }
}
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages