Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-422

Timer based rules don't fire and facts can't expire after session restore

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Pull Request Sent (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 5.5.0.Final
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      I have implemented a custom persistence engine for Drools sessions in MongoDB. When session is built for first time, everything works like a charm. I am having some problems when Drools sessions are restored from MongoDB collection. Firstly, interval based rules (for example timer(int: 10s 10s)) don't fire. Some facts that should expire, they just don't expire and remain forever in WM. I attached the source code. When session is built for first time, I use code like this:

      KnowledgeBase kbase = createKBase(getKnowledgeBuilder(rulePackagePath),
      config);

      if (hasKnowledgeAgent)

      { createKnowledgeAgent(kbase, correlatorId); wm = (ReteooStatefulSession) ((KnowledgeBaseImpl) kagent .getKnowledgeBase()).ruleBase.newStatefulSession( (SessionConfiguration) ksconf, env); ksession = new StatefulKnowledgeSessionImpl(wm, kagent .getKnowledgeBase()); stateOutputMarshaller = StateMarshallerFactory.newOutputMarshaller(this, ksession, ksconf); stateOutputMarshaller.init(); ((InternalKnowledgeRuntime) ksession).setEndOperationListener(this); }

      Then, after every action I update the session in MongoDB collection.

      public void endOperation(InternalKnowledgeRuntime ikr)

      { stateOutputMarshaller.marshall(); }

      For session restoring, after AS restart I use this code:

      KnowledgeBase kbase = createKBase( getKnowledgeBuilder(rulePackagePath), getKBaseConfig() );
      stateInputMarshaller = StateMarshallerFactory.newInputMarshaller( this, kbase, getSessionConf() );
      ksession = stateInputMarshaller.unmarshall(correlatorId);
      stateOutputMarshaller = StateMarshallerFactory.newOutputMarshaller( this, ksession, getSessionConf() );

      ((InternalKnowledgeRuntime)ksession).setEndOperationListener(this);

      protected static KnowledgeBaseConfiguration getKBaseConfig()

      { KnowledgeBaseConfiguration config = KnowledgeBaseFactory .newKnowledgeBaseConfiguration(); config.setOption(EventProcessingOption.STREAM); return config; }

      protected static KnowledgeSessionConfiguration getSessionConf()

      { KnowledgeSessionConfiguration ksconf = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); ksconf.setOption(ClockTypeOption.get("realtime")); return ksconf; }

      Any help is appreciated.

      Thanks

        Attachments

          Activity

            People

            Assignee:
            mark.proctor Mark Proctor
            Reporter:
            nedoo Nedo Nedic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: