5 Replies Latest reply on Oct 9, 2013 1:51 AM by swiderski.maciej

    A statefulknowledgesession question

    wangtrash

      Hi, all

          In the user guide, I found the statefulknowledgesession must be release by using dispose function, otherwise the memory the session used would not be free. But in my process, I have several subprocesses and service tasks to do some works. I found after startProcess, the session could not be release at once. where can I use the dispose function?

        • 1. Re: A statefulknowledgesession question
          swiderski.maciej

          it completely ok to keep session active when is needed - like in your case. For example jbpm console uses single session that is active all the time so there is no need to actually dispose it. Disposal of ksession is important if you have many instances of them.

          Memory consumption will not be high as process instances are persisted in db when not executed like when being in wait state.

           

          HTH

          1 of 1 people found this helpful
          • 2. Re: A statefulknowledgesession question
            wangtrash

            Thanks for your reply. I'm a newbie. I use the jbpm in a web application.  in fact, I permit users to define their processs  using the designer. every time, a user need start a process, I will new a knowledgebase and then start a new statefulesession. In this case, is disposal a ksession is important?

            • 3. Re: A statefulknowledgesession question
              swiderski.maciej

              yes, it is important in that case as you would have many ksessions. So I would recommend for you to create some sort of mapping mechanism for the process instance and ksession so you can dispose the ksession as soon as possible (it reached wait state) and then use the right session to resume it like when completing task or signaling.

               

              HTH

              • 4. Re: A statefulknowledgesession question
                wangtrash

                Is that mean I must write a processeventlistener and signal to dispose the session when the main process is over?

                • 5. Re: A statefulknowledgesession question
                  swiderski.maciej

                  yes, you could do that but please note that you can't dispose it directly in the event listener as it is still using ksession and thus you would need to use transaction synchronization to dispose ksession after transaction has been completed. Take a look here as it might get helpful.

                   

                  HTH