4 Replies Latest reply on Jun 12, 2007 4:38 PM by lachelt

    How to tell if token is waiting?

    lachelt

      Is there a way to determine whether a token is waiting?

      Another way to ask this... when I call getNode() on a token, does that mean the token is waiting at that node?

      I'm still trying to understand what it means that the process executes in the thread that signals the process instance. Does that also mean that other threads would not "see" the fact that the process is moving through the nodes until that thread reaches a wait state?

        • 1. Re: How to tell if token is waiting?

          Jon,

          Threads don't share hibernate caches on the same process instance. If another thread looks at the token, it's going to have fetched it independently from the database.

          The database is updated when the token reaches a wait state.

          >> I'm still trying to understand what it means that the process executes in the thread that signals the process instance.

          Me too. If subsequent actionhandlers do a signal or leaveNode, the execution is recursive. So in a loop with no wait states, each iteration grows the stack (and everything it refers to on the heap). This seems ugly, but I can't decide how bad it is. While a QA team would run into it quickly, I'm not sure it has much real-world consequence.

          -Ed Staub

          • 2. Re: How to tell if token is waiting?
            lachelt

             

            The database is updated when the token reaches a wait state.


            That's what I supposed, but wasn't sure. Thus, that tells me that if a separate thread gets the node for a token, then that means the token is in a wait state at that node. I guess it might actually be in the middle of running some other node following that node - but I can't find that out since that info hasn't been persisted yet.

            Thanks for your insight,
            -Jon

            • 3. Re: How to tell if token is waiting?
              kukeltje

              do you want to manipulate the token from 2 threads, or do you just want to make sure you know what node it is in? The former is bad practise the second should be a method on your own first thread and ask there what state the token is in.

              • 4. Re: How to tell if token is waiting?
                lachelt

                Thanks for clarifying. No, I do not want to manipulate the token from the other thread. I figured that was a no-no. From my other thread I just want to know what node it is on. We want to provide users with some insight into what state the workflow is in.

                In this case I think it is acceptable for the user to only have visibility into the previous rest state of a process. Any "long running" step in the workflow should be done asynchronously... the node should post some external request, and wait until that request has been satisfied.

                If the workflow is marching along through some simple nodes that don't take much time (e.g. a decision node, or query to the DB) then the user would have to be aware that by the time they looked at the output of their request the workflow would already be beyond that point anyway. Probably at the next wait state.

                At least that's my thought. Please let me know if I've said anything that doesn't sound right.
                -Jon