Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-2570

KnowledgeAgent lacks a safe disposal method

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    Description

      In the old RuleAgent api, there were a couple methods exposed that provided a safe disposal/cleanup mechanism:
      > ragent.stopPolling();
      > for (StatefulSession s : ragent.getRuleBase().getStatefulSessions())

      { s.dispose(); }

      In the new KnowledgeAgent api, there is only:
      > kagent.monitorResourceChangeEvents(false);

      This is problematic for a few reasons:
      1. Calling kagent.monitorResourceChangeEvents(false) will stop the thread that reads changesets from the queue and processes them, but the kagent will remain as a notifier listener. So the kagent will continue putting a changeset on its queue whenever the scanner detects a change, the result of this being a memory leak.
      2. Without a way to get at the KnowledgeBase and it's StatefulKnowledgeSessions, there is no way to cleanly dispose them.
      3. There is currently no way for the ResourceChangeScannerService to know that it should stop "watching" a resource, because it doesn't know when there are no more listeners registered with the ResourceChangeNotifierService. The result of this is unnecessary overhead.

      To solve #1 and #2 above, a dispose() method should be added to KnowledgeAgent that will:
      a. Remove itself as a notifier listener.
      b. THEN call monitorResourceChangeEvents(false) to stop it's internal thread.
      c. Clear it's internal queue.
      d. Iterate over any StatefulKnowledgeSessions associated with it's KnowledgeBase, and dispose() them.

      It could be argued that #3 above should be a separate Jira issue, but it is related to this topic, so it deserves mentioning.

      Notes:
      1. This issue is a dependency for JBoss.org ESB 4.9, which is a dependency for JBoss.com SOA-P 5.1. The dependent Jira issue is: JBESB-3360.
      2. This issue has been marked as Critical, although I would consider it a Blocker. However, I will leave that decision up to the Drools team.

      Attachments

        Issue Links

          Activity

            People

              dward-se-jboss David Ward
              dward-se-jboss David Ward
              Archiver:
              rhn-support-ceverson Clark Everson

              Dates

                Created:
                Updated:
                Resolved:
                Archived:

                PagerDuty