3 Replies Latest reply on Sep 27, 2012 1:50 PM by Maciej Swiderski

    Pattern of using StatefulKnowledgeSession in web application

    wqe wqe Newbie

      Suppose the current flow stop at a human task , we have to call StatefulKnowledgeSession.getWorkItemManager().completeWorkItem(workItemId , null) to complete this human task manually. What is the difference when using StatefulKnowledgeSession in the following cases?  

       

      1.  Use StatefulKnowledgeSession which create this process to complete this human task

      2. Use a new StatefulKnowledgeSession  to complete this human task

       

      I found that result of both the above approach seems to be the same.

       

      If the answer is "no differences" , and StatefulKnowledgeSession  is confirmed to be thread-safe ( So does StatefulKnowledgeSession really thread-safe? )    , can we simply use an application-scoped StatefulKnowledgeSession in the web application ?

        • 1. Re: Pattern of using StatefulKnowledgeSession in web application
          Maciej Swiderski Master

          there is no difference if you do not keep any state in your session like facts (for rules evaluation) or timers.

           

          As far as I know StatefulKnowledgeSession is thread safe. For instance jbpm console uses application (single session) scoped session, so I would say it is fine but of course it depends on your requirements.

           

          HTH

          1 of 1 people found this helpful
          • 2. Re: Pattern of using StatefulKnowledgeSession in web application
            wqe wqe Newbie

            Maciej Swiderski wrote:

             

            there is no difference if you do not keep any state in your session like facts (for rules evaluation) or timers.

             

            Does it mean that there are no difference if the process does not involve any timer event or rules evaluation event ?

             

            In other words , can I say that if the process contains  timer event or rules evaluation event , then the StatefulKnowledgeSession cannot be application (single session) scoped?

            • 3. Re: Pattern of using StatefulKnowledgeSession in web application
              Maciej Swiderski Master

              wqe wqe wrote:

              Does it mean that there are no difference if the process does not involve any timer event or rules evaluation event ?

              we can say so, in terms of working with process instances - meaning if session 1 started a process session 2 can complete it. It does not have to be same session if you don't use its state (facts, timers). But if you do, then same session should be used to ensure the right context for execution.

               

               

              wqe wqe wrote:

               

              In other words , can I say that if the process contains  timer event or rules evaluation event , then the StatefulKnowledgeSession cannot be application (single session) scoped?

              That depends on your process definitions, if they can coexists even thou there are shared state they you could do it. That would also depend on your rules definitions.

               

              HTH