[jboss-jira] [JBoss JIRA] Created: (JBRULES-2570) KnowledgeAgent lacks a safe disposal method

David Ward (JIRA) jira-events at lists.jboss.org
Fri Jul 9 12:01:47 EDT 2010


KnowledgeAgent lacks a safe disposal method
-------------------------------------------

                 Key: JBRULES-2570
                 URL: https://jira.jboss.org/browse/JBRULES-2570
             Project: Drools
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: drools-core  (expert)
    Affects Versions: 5.1.0.M2
            Reporter: David Ward
            Assignee: Esteban Aliverti
            Priority: Critical
             Fix For: 5.1.0.CR1


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.monitorResourceChangeEvent(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 topics, 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.  A related Jira issue will be linked.
    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.  ;)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the jboss-jira mailing list