Vishesh-Mukherjee opened a new issue, #6423:
URL: https://github.com/apache/incubator-kie-drools/issues/6423

   Hello,
   
   When I'm deleting the rule from the `KieBase` and then adding the same rule 
in the same file again in the `KieFileSystem`, building it, updating the 
existing `KieContainer`, and firing the rules. Then the same rule is not 
getting fired even though there are no errors while building the 
`KieFileSystem`.
   
   What I have observed is:
   1. After the deletion, if I'm adding a new rule along side the one that I 
had previously deleted, then the new rule is getting fired.
   2. If I'm adding the rule that I have previously deleted in a file with 
different name, then the rule is getting fired.
   3. If I'm building a `newKieContainer` rather than update the existing one, 
then the rule is getting fired.
   
   Below is the minimum code required to replicate the isssue
   Entity:
   ```java
   public class Txn {}
   ```
   Main:
   ```java
   public class DemoApplication {
   
       private final static String TEMPLATE = "package demo;\n" +
               "import org.drools.examples.demo.Txn;\n" +
               "rule \"template\"\n" +
               "when\n" +
               "m: Txn()\n" +
               "then \n" +
               "System.out.println(\"template Fired\");\n" +
               "end";
   
       private final static KieServices kieServices = KieServices.get();
   
       public static void main(String args[]) {
   
           KieModuleModel kieModuleModel = kieServices.newKieModuleModel();
           KieBaseModel kieBaseModel = 
kieModuleModel.newKieBaseModel("demo_base");
           kieBaseModel.addPackage("demo");
           kieBaseModel.newKieSessionModel("demo_session");
   
           buildRules(kieModuleModel.toXML(), "foo");
           KieContainer kieContainer = 
kieServices.newKieContainer(kieServices.getRepository().getDefaultReleaseId());
           fireRules(kieContainer);
   
           deleteRules(kieContainer, "foo");
   
           buildRules(kieModuleModel.toXML(), "foo", "bar");
           
kieContainer.updateToVersion(kieServices.getRepository().getDefaultReleaseId());
           fireRules(kieContainer);
       }
   
       private static void deleteRules(KieContainer kieContainer, String... 
ruleNames) {
           for (String ruleName : ruleNames) {
               kieContainer.getKieBase("demo_base").removeRule("demo", 
ruleName);
           }
       }
   
       private static void fireRules(KieContainer kieContainer) {
           KieBase kieBase = kieContainer.getKieBase("demo_base");
           KieSession kieSession = kieBase.newKieSession();
           kieSession = kieBase.newKieSession();
           Txn transaction = new Txn();
           kieSession.insert(transaction);
           kieSession.fireAllRules();
       }
   
       private static void buildRules(String kieModuleXML, String... ruleNames) 
{
           KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
           kieFileSystem.writeKModuleXML(kieModuleXML);
           for (String ruleName : ruleNames) {
               String fileContent = TEMPLATE.replaceAll("template", ruleName);
               kieFileSystem.write("src/main/resources/demo/" + ruleName  + 
"_rule.drl", fileContent);
           }
           kieServices.newKieBuilder(kieFileSystem).buildAll();
       }
   
   }
   ```
   
   Actual Output
   ```
   foo Fired
   bar Fired
   ```
   
   Expected Output
   ```
   foo Fired
   foo Fired
   bar Fired
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to