5 Replies Latest reply on Jul 5, 2010 5:39 AM by rebody

    Multi-threaded process execution?

    cntoomey

      Has anybody implemented extensions to support multi-threaded process execution of fully-automated (no human tasks) workflows?

      I'm looking at using jbpm for executing such workflows in a web application, and for performance need to be able to execute parallel branches concurrently in separate threads.  The nodes in the workflows would be Java modules that execute computational or data-gathering tasks.

       

      I've got some rough ideas on how to do it, but am hoping someone's already done it or at least spent some time thinking though how best to do it.

       

      thx,

      Chris

        • 1. Re: Multi-threaded process execution?
          rebody

          Hi Chris,

           

          If you want to each branches of forked executions could be invoked in a seperated thread.  you could use continue="async".  You could find more information in dev-guide: http://docs.jboss.com/jbpm/v4/devguide/html_single/#jobexecutor

          1 of 1 people found this helpful
          • 2. Re: Multi-threaded process execution?
            cntoomey

            Thanks HuiSheng, ya I'd seen that but it looked pretty complicated and heavyweight, particularly triggering DB write and transactions for each such asynch node.  In the fully in-process web-request-processing application I'm looking at I want to avoid transactions altogether.  Looks like either I couldcreate and use my own lighter-weight MessageService implementation instead, or else do it another way e.g. w/ custom Fork and Join node implementations.

             

            Chris

            • 3. Re: Multi-threaded process execution?
              rebody

              Hi Chris,

               

              Let jBPM 4 support real Multi-Thread will be a good research direction.  But please notice some thing.  That the IoC containter of jBPM 4 based on the TheadLocal,  so if you create Multi-Thread in your custom activity, you maybe have to face some problems, e.g. you cannot get components directly from Environment any more.  And the transaction interceptor should be rewrite for Multi-thread scenario, you have to find a way to notify the interceptor when all of executions have completed,  and whether the current transation could commit or should rollback.

               

              So the current implementation of jBPM 4 based on the single-thread scenario could simplify many problem and easy to achieve.  if you really want to achieve a Multi-Thread solution,  please consider about these.

               

              Good Luck.

              1 of 1 people found this helpful
              • 4. Re: Multi-threaded process execution?
                cntoomey

                Ok, thanks for the heads-up about that.  What's the IoC container?

                 

                Chris

                • 5. Re: Multi-threaded process execution?
                  rebody

                  Hi Chris,

                   

                  jBPM 4.x provide a IoC container to maintain all of internal components.  Each time we saw EnvironmentImpl.getFromCurrent(),  it means that we get a component from IoC container.

                   

                  The EnvironmentImpl use ThreadLocal to store the current context which stored component,  so it maybe cannot be used in Multi-Thread scenario directly.