2 Replies Latest reply on Oct 29, 2014 4:45 AM by chetan.math

    jbpm 6.0.0 : How to dynamically change/update knowledge base without restarting the application

    chetan.math

      I am developing a simple application which currently has one workflow and I use PerRequest strategy. I am using jbpm api's  to to manage the process state.

      On server startup I create the RuntimeManager (sample code snippet).  Currently the bpmn file are in the classpath but I plan to move it to a file system or database .

      Hence if I add new workflows to the filesystem or database , I would want my knowledge base to be refreshed to recognize the new workflows . Do we have any api that helps us do it . I do not want to restart my server every time a new workflow is added.

       

       

      public RuntimeManager getRuntimeManager() {

              UserGroupCallback userGroupCallback = new MyUserGroupCallback();

              RuntimeEnvironment environment = RuntimeEnvironmentBuilder.getDefault()

                      .entityManagerFactory(Persistence.createEntityManagerFactory("org.jbpm.persistence.jpa"))

                      .userGroupCallback(userGroupCallback)

                      .addAsset(ResourceFactory.newClassPathResource("bpmn/test.bpmn"), ResourceType.BPMN2).get();

              RuntimeEnvironmentBuilder.

              runtimeManager = RuntimeManagerFactory.Factory.get().newPerRequestRuntimeManager(environment);

              return runtimeManager;

          }

       

      In jbpm user guide , Chapter 5. Core Engine API we have

       

      " A knowledge base can be shared across sessions and usually is only created once, at the start of the application (as creating a knowledge base can be rather heavy-weight as it involves parsing and compiling the process definitions). Knowledge bases can be dynamically changed (so you can add or remove processes at runtime)."

      Hence I wanted to know how to update the knowledge base at runtime.

       

      Currently as recommended in the user guide I am following the below.

      1. At application startup

      build RuntimeManager and keep it for entire life time of the application

      2.

      get RuntimeEngine from RuntimeManager

      get KieSession and/or TaskService from RuntimeEngine

      perform operations on KieSession (start,complete)

      once done with processing dispose RuntimeEngine using RuntimeManager.disposeRuntimeEngine method

      3. At application shutdown

      close RuntimeManager

       

      Please suggest.