title: Read .xlsx File from Drool Engine Dynamically without restarting spring project
body: <p>I am trying to read my excel file using drool I am able to successfully read the file from s3 but the problem comes when I make changes to that file and replace the existing file with new file my rule engine still reads old file values can anyone tell what can be done to resolve this issue</p>
  <p>Dto</p>
  <pre><code>package com.example.demo;
  import lombok.Getter;
  import lombok.Setter;
  import lombok.ToString;
  import org.springframework.cloud.context.config.annotation.RefreshScope;
  import org.springframework.stereotype.Component;
  
  @Getter
  @Setter
  @ToString
  @Component
  @RefreshScope
  public class DataDTO {
      String firstName;
      String lastName;
  }
  </code></pre>
  <p>Drool Config</p>
  <pre><code>   package com.example.demo.Config;
   import lombok.extern.slf4j.Slf4j;
   import org.drools.decisiontable.DecisionTableProviderImpl;
   import org.kie.api.KieServices;
   import org.kie.api.builder.*;
   import org.kie.api.io.Resource;
   import org.kie.api.runtime.KieContainer;
   import org.kie.api.runtime.KieSession;
   import org.kie.internal.io.ResourceFactory;
   import org.springframework.cloud.context.config.annotation.RefreshScope;
   import org.springframework.context.annotation.Bean;
   import org.springframework.context.annotation.Configuration;
  
   import java.io.IOException;
  
   @Configuration
   @Slf4j
   @RefreshScope
   public class DroolConfig {
  
       private KieServices kieServices = KieServices.Factory.get();
  
       public KieFileSystem getKieFileSystem() throws IOException {
           KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
           Resource resource;
           log.info(&quot;File read form local resource folder&quot;);
           resource = ResourceFactory
               .newUrlResource(&quot;awsurl/123.xlsx&quot;);
           kieFileSystem.write(resource);
           DecisionTableProviderImpl decisionTableProvider
               = new DecisionTableProviderImpl();
           String leadBox = decisionTableProvider.loadFromResource(resource, null);
           log.info(&quot;Rules Loaded from LeadBoxFile:{}&quot;, leadBox);
           return kieFileSystem;
       }
  
       @Bean
       @RefreshScope
       public KieContainer getKieContainer() throws IOException {
           getKieRepository();
           KieBuilder abc = kieServices.newKieBuilder(getKieFileSystem());
           abc.buildAll();
           KieModule kieModule = abc.getKieModule();
           KieContainer kContainer = kieServices.newKieContainer(kieModule.getReleaseId());
           return kContainer;
       }
  
       private void getKieRepository() {
           final KieRepository kieRepository = kieServices.getRepository();
           kieRepository.addKieModule(new KieModule() {
               public ReleaseId getReleaseId() {
                   return kieRepository.getDefaultReleaseId();
               }
           });
       }
  
       @Bean
       public KieSession getKieSession() throws IOException {
           return getKieContainer().newKieSession();
       }
   }
  </code></pre>
  <p>Controller</p>
  <pre><code>package com.example.demo;
  
  import com.example.demo.Config.DroolConfig;
  import org.kie.api.runtime.KieContainer;
  import org.kie.api.runtime.KieSession;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.*;
  
  import java.io.IOException;
  
  @RestController
  @RequestMapping(&quot;/v2&quot;)
  public class LoadData {
      @Autowired
      private KieSession kieSession;
  
      @Autowired
      private final KieContainer kieContainer;
  
      @Autowired
      DroolConfig droolConfig;
  
      public LoadData(KieSession kieSession, KieContainer kieContainer) {
          this.kieSession = kieSession;
          this.kieContainer = kieContainer;
      }
  
      @PostMapping(&quot;/printData&quot;)
      public String printData(@RequestBody DataDTO dataDTO) throws IOException {
          KieSession kieSession = kieContainer.newKieSession();
          kieSession.insert(dataDTO);
          kieSession.fireAllRules();
          kieSession.dispose();
          return dataDTO.getLastName();
      }
  
      @GetMapping(&quot;/loadDroolFile&quot;)
      public String getDroolData() throws IOException {
          droolConfig.getKieFileSystem();
          kieContainer.getKieSessionConfiguration();
          return &quot;Done&quot;;
      }
  }
  </code></pre>
  <p>Whenever I try to hit loadDroolFile I am able to get refreshed data but the data does not get injected I still get the result from drool engine using old values</p>