2 Replies Latest reply on Mar 24, 2015 2:35 AM by Maciej Swiderski

    jbpm6 session management

    chiaan Hung Novice

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


      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.

      TaskService taskService;



          1. where can I dispose ksession?

          2. Which way I can use to dispose ksession?






      ksession.insert(manager or ksession);

              Can I dispose ksession at rule task?

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


      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.)



        • 1. Re: jbpm6 session management
          chiaan Hung Novice

          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");


          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.


          • 2. Re: jbpm6 session management
            Maciej Swiderski Master

            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.