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

KnowledgeAgent unsubscribes monitors, doesn't resubscribe them

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 5.2.0.M2
    • 5.1.1.FINAL
    • drools-core
    • None
    • Hide

      1. Create a .drl file.
      2. Set up a KnowledgeAgent to monitor it. The bug exists whether the agent is set to scan directories or not. Make sure the agent is set to scan resources. Make sure the agent is set to perform incremental builds.
      3. Let the agent make the initial build.
      4. Edit the .drl file so that it is invalid.
      5. Watch and see that after the agent cannot build the .drl file it will report that it is subscribed to 0 resources.

      Show
      1. Create a .drl file. 2. Set up a KnowledgeAgent to monitor it. The bug exists whether the agent is set to scan directories or not. Make sure the agent is set to scan resources. Make sure the agent is set to perform incremental builds. 3. Let the agent make the initial build. 4. Edit the .drl file so that it is invalid. 5. Watch and see that after the agent cannot build the .drl file it will report that it is subscribed to 0 resources.

    Description

      A KnowledgeAgent set up to monitor a .drl file, and set to perform incremental builds, will correctly monitor that file for changes.

      When a change to that file, however, results in a DRL syntax exception (or any other KnowledgeBuilder errors), the KnowledgeAgent no longer monitors the resource for changes.

      This means that a typo in the file effectively stops the KnowledgeAgent from ever seeing that file again. Consequently, an error in the DRL file requires a restart to whatever server is using the KnowledgeAgent.

      Esteban and I have found that the error is related to lines 337 and following of KnowledgeAgentImpl.java. Here is a snippet from one of his emails to me:

      "The problem seems to be related to the lines you mentioned. When a resource is modified, all its knowledgeDefinition->resource are cleared and reconstructed later. I don't see any reason to unsubscribe the listener though. So the call to Set<KnowledgeDefinition> definitions = this.removeResourceMapping(resource, true); should be Set<KnowledgeDefinition> definitions = this.removeResourceMapping(resource, false);

      "That means: remove all the mappings but don't unsubscribe me (the kagent) as a listener."

      Further background can be found at http://drools-java-rules-engine.46999.n3.nabble.com/Drools-5-1-What-happens-when-an-incremental-KA-rebuild-fails-td2258083.html

      Attachments

        Activity

          People

            esteban.aliverti@gmail.com Esteban Aliverti (Inactive)
            ljnelson+github@gmail.com Laird Nelson (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Resolved:
              Archived:

              PagerDuty