title: Drools 6.5 Executing Specific Rule Using a Custom Agenda Filter Not Working
body: <p>I have a requirement to execute specific rules using their using associated values and tried implementing a custom Agenda Filter to only execute one particular rule at a time but it appears to execute all rules. I'm using a stateless session that i defined like this:</p>
  
  <pre><code>   @Bean
       @ConditionalOnMissingBean(KieSession.class)
       public StatelessKieSession kieSession() throws IOException {   
           return kieContainer().newStatelessKieSession();
       } 
  </code></pre>
  
  <p>My logic for iterating the Map and executing each rule is as follows:</p>
  
  <pre><code>for (Map.Entry&lt;Long, String&gt; entry : ruleIdsAndData.entrySet()){
  
      List&lt;Object&gt; facts = new ArrayList&lt;Object&gt;();
      facts.add(entry.getValue());
  
      Map&lt;String, String&gt; ruleResponse = new HashMap&lt;String, String&gt;();
      kieSession.setGlobal("ruleResponse", ruleResponse);                     
  
      TrackingAgendaEventListener agendaEventListener = new TrackingAgendaEventListener();
      kieSession.addEventListener(agendaEventListener);
  
      String ruleName = myRuleService.retrieveRuleNameById(entry.getKey());               
      log.debug("Attempting to fire the following rule : " + ruleName);
  
      facts.add(new FireAllRulesCommand(new RuleNameEqualsAgendaFilter(ruleName)));   
      kieSession.execute(facts);
  
      log.debug("RuleResponse after rule has fired is : " + ruleResponse);                                                            
  }
  </code></pre>
  
  <p>and the <code>RuleNameEqualsAgendaFilter</code> class looks like this:</p>
  
  <pre><code>import lombok.extern.slf4j.Slf4j;
  import org.kie.api.runtime.rule.AgendaFilter;
  import org.kie.api.runtime.rule.Match;
  
      @Slf4j
      public class RuleNameEqualsAgendaFilter implements AgendaFilter {
  
          private final String ruleName;
  
          private final boolean accept;
  
          public RuleNameEqualsAgendaFilter(final String name) {
              this(name, true);
          }
  
          public RuleNameEqualsAgendaFilter(final String name, final boolean accept) {
              this.ruleName = name;
              this.accept = accept;
          }
  
          public String getName() {
              return ruleName;
          }
  
          public boolean isAccept() {
              return accept;
          }
  
          public boolean accept( Match match) {
              log.debug("Comparing : " + match.getRule().getName() + " to ruleName : " + this.ruleName);
              if (match.getRule().getName().equals(this.ruleName)) {
                  return this.accept;
              } else {
                  return !this.accept;
              }
          }
      }
  </code></pre>
  
  <p>Any ideas why this would execute a different rule to the one i specify in <code>ruleName</code>?</p>