2 Replies Latest reply on Mar 24, 2015 2:35 AM by swiderski.maciej

    jbpm6 session management

    c00823ue

            I create runtime manager by cdi. I use jbpm 6.0.0.Final.

       

      @Inject
      @PerRequest
      private RuntimeManager manager;
      
      
      
      

       

          Then I use runtime manager to create kiesession.

       

      RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
      KieSession ksession = runtime.getKieSession();
      
      
      
      

       

        I create taskservice by cdi.

      @Inject
      TaskService taskService;
      
      
      
      

       

       

          1. where can I dispose ksession?

          2. Which way I can use to dispose ksession?

             (

      ksession.dispose();
      
      
      
      

                             or

      manager.disposeRuntimeEngine(runtime);
      manager.close();
      
      
      
      

                             or

      ksession.insert(manager or ksession);
      ksession.fireAllRules();
      
      
      
      

              Can I dispose ksession at rule task?

             (I can dispose ksession at the end of the process.)

                            or

      ksession.setGlobal("ksession", ksession);
      ksession.setGlobal("manager", manager);
      
      
      

             Can I dispose kiesession by global variable "ksession" or "manager"?

            (I can dispose ksession at the end of the process.)

            

             )

        3.  Now I approve task by taskService. How can I do that after I dispose ksession?

            (If I cannot use 3 or 4 options of question2, then I need to know that.)

        4. Is it possible to know number of session at a moment in wildfly-8.1.0.Final?

            (I create KieSession by Per Request strategy.)

       

      Thanks!

        • 1. Re: jbpm6 session management
          c00823ue

          I use two call activities in bpmn process file. I put a script task right before end event (Terminate) of parent process. The follwing is the content of script task.

           

          System.out.println("kcontext dispose session");
          kcontext.getKieRuntime().dispose();
          

           

          However, I got the error

              Caused by: java.lang.IllegalStateException: Illegal method call. This session was previously disposed.

          Why session is already disposed? The error log is attached.

          Thanks!

          • 2. Re: jbpm6 session management
            swiderski.maciej

            whenever you use runtime manager you should use disposeRuntimeEngine on manager which will dispose the ksession internally. Alternatively you can get runtime manager within active JTA transaction the runtime engine will be disposed automatically at transaction completion.

             

            HTH