Memory decline when use drools stream mode -
i use drools 6.2.final fusion cep, , have set event @expires (1d), found memery have been declining few days later. every day total of event data not much.i doubt event in working memery after expiration not clear.so want confirm something:
1.fusion cep stream mode stateful session must dispose() after fireallrules()? in code ksession create once @ init method, , use insert event , fire rules, never use dispose() method after fire. i'm worried not did not use method caused event has been kept in memory.
2.the event after expiration automatically removed memory? fear event not 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 , 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); } // .... }
after test found why event has not been removed correctly.i need declare @expires in rule this:
declare event @role(event) @timestamp(begintime) @expires(2m) end
and comment not take effect add above class event.
@org.kie.api.definition.type.timestamp("begintime") @org.kie.api.definition.type.expires("1d") public class event{....}
Comments
Post a Comment