Reputation: 21
I use Drools 6.2.Final Fusion CEP, and i have set event @expires (1d), but i found that the memery have been declining few days later. Every day the total of event data is not much.I doubt the event in working memery after the expiration is not clear.so i want to confirm something:
1.Fusion CEP stream mode Stateful session is must dispose() after fireAllRules()? In my code the ksession will only create once at the init method, and then use it insert an event and fire all rules, but i never use the dispose() method after fire. I'm worried about is not that I did not use the method that caused the event has been kept in memory.
2.The event after the expiration will automatically removed from memory? I fear that the event is not properly cleared, resulting in memory has been declining.
@org.kie.api.definition.type.Role(org.kie.api.definition.type.Role.Type.EVENT)
@org.kie.api.definition.type.TypeSafe(true)
@org.kie.api.definition.type.Timestamp("beginTime")
@org.kie.api.definition.type.Expires("1d")
public class Event{
private Long beginTime;
// ...other fields, set and get method..
}
--
poublic void initKsession()throws Exception{
KieServices kieServices = KieServices.Factory.get();
KieBaseConfiguration config = KieServices.Factory.get().newKieBaseConfiguration();
config.setOption(EventProcessingOption.STREAM);
ReleaseId releaseId = kieServices.newReleaseId(groupId, artifactId, version);
KieContainer kContainer = kieServices.newKieContainer(releaseId);
KieScanner kScanner = kieServices.newKieScanner(kContainer);
kSession = kContainer.newKieSession(kessionName);
kScanner.start(10000L);
}
--
public Result processRules(Event event) {
// ....
try {
kSession.insert(event);
kSession.fireAllRules();
} catch (Exception e) {
log.error("fail",e);
}
// ....
}
Upvotes: 1
Views: 447
Reputation: 21
After the test I found why the event has not been removed correctly.I need to declare @expires in a rule like this:
declare Event
@role(event)
@timestamp(beginTime)
@expires(2m)
end
And the comment does not take effect where i add above the class Event.
@org.kie.api.definition.type.Timestamp("beginTime")
@org.kie.api.definition.type.Expires("1d")
public class Event{....}
Upvotes: 1