Hello
I'm trying to find information around how I can configure my SpringBoot application to load rules for a stateful KieSession that have changed via a change propagated through the KIE workbench. I have the code that does most of it, but some questions still remain. The following snippet will likely help the conversation -
@Inject
@KContainer(name = "dynamic-rules-container")
@KReleaseId(groupId = "
com.org", artifactId = "ops", version = "LATEST")
private KieContainer kieContainer;
private void executeOpsRules() {
// Get the latest release
ReleaseIdImpl releaseId = new ReleaseIdImpl("
com.org", "ops", "LATEST");
kieContainer.updateToVersion(releaseId);
KieSession kSession = kieContainer.newKieSession("ops-session");
if ( kSession!=null ) {
// Get fact data
....
// Add facts
kSession.insert(factA);
kSession.insert(factB);
// Fire rules
kSession.fireAllRules();
}
}
Firstly, is there a way for me to avoid the "updateToVersion" call? KIE-CI should be able to handle this if its in the application's classpath is what I read. But it doesn't seem to do this, making it necessary for me to invoke this on the container. Also, the maven terminology of picking up latest version deployed via the "LATEST" version value does not take hold even if the Rule deployment environment in workbench has a scanner setup to run ever so often to pick up the latest version of the release. Feels like a bug, since I actually have to give an exact version everywhere for the above to work. At this point I've gotten around the whole issue by actually putting "LATEST" as part of the Project container version.
The other part seems to be that I do not get a handle to a stateful kieSession. Though it is marked as stateful, the facts that were inserted earlier like in the above "factA" & "factB" do not show up the next time those rules are fired on that session - because it looks like I get a handle to a new stateful session, even though I'm not disposing the old session. Also, there doesn't seem to be a way to get the old session through the APIs (like possibly using ID which is now deprecated ). Only way around this has been to create the KieSession as a singleton bean in Spring but that prevents rules loading dynamically as initialization will not get called every time for "updateToVersion" to be invoked.
Appreciate any guidance or pointers on this at this point....
Thanks
Amit