Runtime strategy PER_REQUEST acts like SINGLETON in Drools Workbench 7.2.0

248 views
Skip to first unread message

Shivansh Gaur

unread,
Dec 8, 2017, 10:33:50 AM12/8/17
to Drools Setup
We have setup Drools Workbench Showcase and KIE Execution Server Showcase from the Docker images available.
Drools Workbench Showcase version 7.2.0.
We are trying to use stateful KIESession with Runtime Strategy as PER_REQUEST, since we want to create a new kie-session for each request and destroy the kie-session after the request is completed.

We changed the runtime strategy from process configuration from SINGLETON to PER_REQUEST.


After saving these changes and making an API request to KIE Execution Server, we are getting the same functionality as Singleton.

The rule I have is:

package com.********.testrequest;

rule "Test count"
when
    $p : Product()
    accumulate(Product(); $cnt: count())
then
    $p.setCount($cnt);
end


My request body is as following:

{
"lookup": "session",
"commands": [
  {
    "insert": {
      "out-identifier": "125",
      "object": {
        "com.********.testrequest.Product": {
        "id": "123",
        "name": "drools 1",
        "count": 0
        }
      },
      "return-object": "true"
    }
  },
  {
    "insert": {
      "out-identifier": "126",
      "object": {
        "com.********.testrequest.Product": {
        "id": "123",
        "name": "drools 2",
        "count": 0
        }
      },
      "return-object": "true"
    }
  },
  {"fire-all-rules": "rule1"}
]
}


My expectation here is that for every post request, the count attribute of each inserted object should be set to 2. But that is not happening. With every new request number of objects inserted before is persistent in session and the session is not getting destroyed.
I may be missing some configurations here or my request body is not correct. Please suggest where I am going wrong.



The KIE Execution Server container config can be found below.


This XML file does not appear to have any style information associated with it. The document tree is shown below.
<response type="SUCCESS" msg="Info for container TestRequest:1.0.24">
<kie-container container-alias="" container-id="TestRequest:1.0.24" status="STARTED">
<config-items>
<itemName>KBase</itemName>
<itemValue>kbase</itemValue>
<itemType>BPM</itemType>
</config-items>
<config-items>
<itemName>KSession</itemName>
<itemValue>ksession</itemValue>
<itemType>BPM</itemType>
</config-items>
<config-items>
<itemName>MergeMode</itemName>
<itemValue>MERGE_COLLECTIONS</itemValue>
<itemType>BPM</itemType>
</config-items>
<config-items>
<itemName>RuntimeStrategy</itemName>
<itemValue>PER_REQUEST</itemValue>
<itemType>BPM</itemType>
</config-items>
<messages>
<content>
Unable to create image reference for container TestRequest:1.0.24 by extension jBPM-UI KIE Server extension due to null
</content>
<severity>WARN</severity>
<timestamp>2017-12-08T15:09:35.030Z</timestamp>
</messages>
<messages>
<content>
Container TestRequest:1.0.24 successfully created with module TestRequest:1.0.1.
</content>
<severity>INFO</severity>
<timestamp>2017-12-08T15:09:35.044Z</timestamp>
</messages>
<release-id>
<artifact-id>TestRequest</artifact-id>
<group-id>com.********</group-id>
<version>1.0.1</version>
</release-id>
<resolved-release-id>
<artifact-id>TestRequest</artifact-id>
<group-id>com.********</group-id>
<version>1.0.1</version>
</resolved-release-id>
<scanner status="DISPOSED"/>
</kie-container>
</response>




Maciej Swiderski

unread,
Dec 8, 2017, 12:07:26 PM12/8/17
to drools...@googlegroups.com
That applies to jbpm execution engine only as it is labeled as process configuration. 

Maciej 

Wiadomość napisana przez Shivansh Gaur <shiva...@nestaway.com> w dniu 08.12.2017, o godz. 16:33:

--
You received this message because you are subscribed to the Google Groups "Drools Setup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-setup...@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-setup/2c89ea46-b8fc-479a-9132-4407492ebef1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shivansh Gaur

unread,
Dec 8, 2017, 12:14:25 PM12/8/17
to Drools Setup
Thanks for the prompt answer.

As per my requirement, I want to create a new stateful session for each request. How do I do it?

With respect to my post request body, I want count attribute to be set always as 2 each time I make API request.

priyan...@nestaway.com

unread,
Dec 8, 2017, 1:28:09 PM12/8/17
to Drools Setup

I am facing the same issue and wanted to know if it is possible to create a stateful session per request in Drools-workbench and kie-server
Reply all
Reply to author
Forward
0 new messages