Drools workbench: Create multiple kie-sessions using Kie Server Java Client API

886 Views Asked by At

I am using Drools workbench 7.17 integrated with Kie execution server. I have created a project within workbench and the project is deployed on kie execution server.

I have configured kie-base and kie-session in project's settings. Defined stateful kie-session as KieSession. I am using Kie Server Java Client API to insert facts into engine.

I am able to do lookup on KieSession. I am going to receive the data for different users and I want to create and maintain separate sessions for each user. When the fact is inserted for the existing user then I should be able to reload kie-session associated with that user.

Is there any way through which iI can achieve this using drools workbench and kie-execution server? I couldn't find any example in kie server documentation to create new session using kie server java client api.

Thanks in advance.

1

There are 1 best solutions below

0
On

If this is the case, a new session is created each time you make a call. No stateful sessions are maintained in the kie-server.

You have 3 solutions :

1) develop a kie-server extension for that but it is difficult to cluster(you will have to serialize the kie session)

2) Use the java API of drools to run the rules on the client-side.

3) make your rules so that the data generated by the rule execution contains the status of your calculation so that calling back drools with initial data + all generated by rules is equivalent to keeping a stateful session for your client session. Drools is quick on inserting data. But now all depends on how much data your insert. A few thousand is nothing.

Regards