Kaile Smith
Kaile Smith

Reputation: 13

How to get the current session name in Drools Rule RHS

I have tried searching through the various levels of indirection of both 'drools' and 'kcontext', but seem to keep running into a wall. Is there a way I can get access to the current session name in a RHS of a rule?

Thanks.

Upvotes: 0

Views: 840

Answers (1)

laune
laune

Reputation: 31300

The "session name" is used as a handle for retrieving the session model from the container. It isn't a property of KieSession.

It's easy to use a global containing the session name:

String sessionName = ...;
KieSession kSession = kContainer.newKieSession( sessionName );
kSession.setGlobal( "sessionName", sessionName );

DRL

global String sessionName;

This might be improved by adding the creation date/time or anything else that identifies session instances (as opposed to session model).

Upvotes: 1

Related Questions