0
votes

Currently, I build Drools rule package (a *.jar file) in Drools Workbench, and deploy it to a KIE server container. To request the service, I just post a XML command like below to the container, which is excerpted from here:

<batch-execution lookup="defaultKieSession">
<insert out-identifier="message" return-object="true" entry-point="DEFAULT">
    <com.arty.drlwb.MyExampleType>
          <message>Hello Worlddddd</message>
    </com.arty.drlwb.MyExampleType>
</insert>
<fire-all-rules/>
</batch-execution>

I can get what I expected. Everything seems OK.

But I found there are two KieSessions in the rule package and don't know which one will be used. If the stateful one is used, and I the post XML command with different facts (messages here) over and over again, all facts will be kept in Drools' working memory as far as I know.

Then, would it cause memory leakage since there's no retract command? If yes, what's the correct way to format the XML command?

1

1 Answers

1
votes

The session you want to use for a batch execution in kie-server can be specified by the attribute lookup in the <batch-execution> element. In your case, the KieSession with name defaultKieSession will be used.

If no lookup attribute is specified, then the KieSession defined as the default (default="true") in the kmodule.xml will be selected. If multiple default sessions are specified in the kmodule.xml (just like in your previous post), then I'm not sure which one will be selected. I would say that it is always a good practice to provide the lookup attribute in your <batch-execution> element to avoid confusion.

Regarding the retraction of facts, given that this operation was renamed as "delete" in Drools 6.x, the command you are looking for is org.drools.core.command.runtime.rule.DeleteObjectCommand. Oddly enough, this command is still being serialized as <retract>.

Hope it helps,