Information Technology Reference
In-Depth Information
KieSessionConfiguration ksconf =
ks.newKieSessionConfiguration();
ksconf.setOption(ClockTypeOption.get(ClockType.PSEUDO.getId()));
KieSession ksession = kbase.newKieSession(ksconf, null);
You can also configure the KIE session clock using the kmodule.xml file by writing
clockType="pseudo" in the ksession tag. Later on, you can access the clock and
advance its time with the following code:
SessionPseudoClock clock = ksession.getSessionClock();
clock.advanceTime(3, TimeUnit.MINUTES);
clock.advanceTime(5, TimeUnit.DAYS);
...
Finally, the last configuration we'll mention here is regarding when to fire the rules. So
far, all examples we saw involve firing rules when a process changes state, which adds
new events to the KIE session. What about the case where you need to trigger a rule when
no new event is added? For example, if you're monitoring the heartbeats of a patient, not
having any events for 15 seconds could mean a heart attack event. For these cases where
rules should be constantly evaluated, there is a method called fireUntilHalt in the
KIE session. This method will continuously evaluate rules that match, and change sliding
windows as time advances. The method will hang the thread, and you can cancel it from
another thread or from a specific rule by calling the halt method on the KIE session ob-
ject.
Search WWH ::




Custom Search