4 Replies Latest reply on Nov 25, 2013 4:08 AM by Vijay U

    Get and Dispose RuntimeEngine for Task Queries?

    Vijay U Newbie

      According to jBPM6.0 user guide:


      At request

      •     get RuntimeEngine from RuntimeManager using proper context instance dedicated to strategy of RuntimeManager
      •     get KieSession and/or TaskService from RuntimeEngine
      •     perform operations on KieSession and/or TaskService such as startProcess, completeTask, etc
      •     once done with processing dispose RuntimeEngine using RuntimeManager.disposeRuntimeEngine method

      Typically, in an application user queries tasks more often than actually starting a process instance. So in such cases, is it a good idea to get RuntimeEngine everytime to use TaskService and dispose after that?


      Following code snippet never uses KieSession. Is it necessary to dispose the engine at the end at every request? And will the taskService be still available after I dispose the runtimeEngine?


      RuntimeManager manager; // Per process instance strategy - at application startup
      public List<TaskSummary> listAllTasksForUser(String username, string locale){
          RuntimeEngine engine = manager.getRuntimeEngine(EmptyContext.get());
          TaskService taskService = engine.getTaskService();
          List<TaskSummary> taskList = taskService.getTasksAssignedAsPotentialOwner(username,locale);
          taskList.addAll(taskService.getTasksOwned(username ,locale));
          return taskList;