7 Replies Latest reply on Nov 13, 2008 9:05 AM by exe

    How can i get inform about running tokens/processes.

    exe


      I have a Message Driven Bean for controlling the processes.
      I need some information about the running processes, wich process/tokens is in waiting state, where can i signal the process to resume executions.
      What is the pattern if i want to create a processManaggerMDB that can
      - start the process (this part is ok :))
      - create a list from waiting process ( i need to create a task for every resumable tokens?)
      -signaling (i want to take a signal for the tokens to resume the process executions. Need i lock the processInstace prevent from the Paralel executions that can occure hibernate exception, and unlock when the executor finished - the process finished or entered a new wait state.-

      thx,


      Janos

        • 1. Re: How can i get inform about running tokens/processes.
          kukeltje

           

          - create a list from waiting process ( i need to create a task for every resumable tokens?)


          No, you can just use the token to acquire more info about it or the node it is in, like name, description etc


          -signaling (i want to take a signal for the tokens to resume the process executions. Need i lock the processInstace prevent from the Paralel executions that can occure hibernate exception, and unlock when the executor finished - the process finished or entered a new wait state.-


          No, not specifically. Signalling should take care of it afaik.


          • 2. Re: How can i get inform about running tokens/processes.
            exe


            My problem is the next:

            First: load process instance send signal to token (now the node thread is running ... )

            while the node is running i load the process instance from an other jbpm context and try to send an other signal i'll get an exception: "Error signalling token: An exception of type "org.hibernate.StaleObjectStateException" was thrown. " is it ok.

            But how can i determine the process has a running unfinished process node (a running action thread in a remoteJbpm context) or not ?
            I load the process instance and start a node execution but the node isn't persisted while the node execution is not finished. I need something like this: loadProcess lockProcess->token.signal but i need to list locked (running) intances.

            I want to create a "process console" to monitor all process instances and send signal if it is possible

            instance 1 (is in node2 wait state) [send signal to token1 t1]

            instance 2 (node2)

            instance 3 (is in node5 wait state) [send signal child token t1][send signal to child token t2]


            Janos





            • 3. Re: How can i get inform about running tokens/processes.
              kukeltje

              First of all, 'nodes' should not be long running in the client thread (the thread from which it is signalled). Use the jBPM async functionality for this.

              The functionality you describe is already in the current jBPM webconsole and will eventually also make it into the new upcoming GWT based console.

              • 4. Re: How can i get inform about running tokens/processes.
                exe

                I think something is missing for me. The current webconsole (3.2.3) lists all process instances.

                |select pi
                from org.jbpm.graph.exe.ProcessInstance as pi
                where pi.processDefinition.id = :processDefinitionId
                order by pi.start desc|

                How can i determine if is the process instance running in another jbpm context and it is not in a waiting state?
                i know GraphSession.findAllProcessInstancesForADefinition returns with all running processes but i don't know if an other context working on the process. example: the other context is working on my custom action:

                public void execute(ExecutionContext executionContext) throws Exception {
                // TODO Auto-generated method stub
                System.out.print("asleep");
                Thread.sleep(60000);
                System.out.print("awake");
                executionContext.leaveNode();
                }


                thx for the support,


                Janos

                • 5. Re: How can i get inform about running tokens/processes.
                  kukeltje

                  Not sure... maybe by getting all tokens of a processinstance and check whether one of them is locked.

                  But instead of focussing on this 'problem' of getting info about running instances (running instances btw are process instances that are started and not suspended and not ended, not necessarily ones where an action is active like you say yourself). What is the real underlying issue? (not in technical terms, but in business terms)

                  • 6. Re: How can i get inform about running tokens/processes.
                    salaboy21

                    If you are in this situation, you are probably with the UI blocked waiting for your method to finish and your process to reach a wait state.

                    I think you should think about the business process issue that is involved with your problem.

                    • 7. Re: How can i get inform about running tokens/processes.
                      exe

                      I think I solved my problem. The problem was i misunderstood the bpm concept. I don't want to steal your time but I explain my problem maybe it can help for somebody.

                      I explain the bussines logic of my bpm:

                      We have some bussines function implamented as a stateless session bean.
                      I'll develop a custom action for every ejb invoke i call this node type with ejbInvoke node. The node invoke the EJB and if the invoke is succes signaling the Token to jump the next node.

                      I dont want to implement indentity I'll delegate the authorization information for the ejb layer. When somebody wants to start a process send a message with ProcessDef and his Identity.

                      The MessageDriven bean is listening on the queue. when a message received the MDB create a jbpmContext put the USER object into the jbpmContext and starts the process. Every "ejbInvoke" node call an ejb method with an USER in the parameter list (gets from the process context). If the EJB invocation falls with security exception the EjbInvoke node will not resume the execution (now our process is in waiting state on the EjbInvoke node) save the process instance and the MDB will be destroyed.

                      A different user can get a list with the processes wich are in waiting state and he can resume the process with his own USER objects. (send a message to the mdb with the USER objects and process id. The mdb will overwrite the user in the process Context with the the new USEER object and resume the process ).

                      If the B user tries to resume the process wich is already resumed by user A but the new state isn't persisted because the node isn't finished. The A user's mdb will get a Hibernate exception.


                      Now I think i found a solutions: The user cannot signaling directly the process execution. When i catch the security exception i insert a "resume process 112" task. The users can get only the task lists not the process instance list and he can complete the task with a resume message, when the user sends a resume message i set the task to complete persist the task state and AFTER resume the process execution from the custome task action. When the b user tries to complete the "resume process 112" he will get a message "the process already started" and a task will disappear from his tasklist because somebody else set to complete the task.

                      thx,

                      Janos