1 Reply Latest reply on Jun 27, 2011 7:34 PM by Kris Verlaenen

    How to Start a Fire-and-Forget Process by another Process?

    Bruce Cui Newbie

      For the recent days I have been fighting with the 5.1 release for a solution of backend batch processes.

       

      For multi-threading, I take an alternative that put the logic in a Thread instance, and start it in the work item handler. Further more, for time consuming tasks, even it's in main signle process, since I found the console was actually running all processes in one main thread, I put the logic in a Thread instance too, and put a signal event after the task. When the thread finishes, it sends back a signal to the process instance and the process will continue. This can make the main thread less occupied, so that other processes can have time to run. These are all alternatives since the framework itself cannot satisfy my expectation by default.

       

      Now I'm thinking how to start one process by another in a fire-and-forget manner. I did some test. By default, even I set the sub-process's "wait for completion" to "false", the parent process would still wait for sub's completion. The exception seems to be that when the sub met some event node, say a timer, even with "delay" set to 0ms, the parent could take the running back.

       

      So I'm thinking to put a timer at the beginning of the sub, right after the start node, which would be another alternative.

       

       

      Could you kindly advise, whether there are any more appropriate means to fulfill the expected functionalities?

       

       

      BTW, I see there is a "Timers" property in some task nodes. But there seems no corresponding content in the user guide. Could you advise on it's function as well?

       

      Thanks,

       

      Bruce

        • 1. Re: How to Start a Fire-and-Forget Process by another Process?
          Kris Verlaenen Master

          I suggest you take a look at the updated docs on multi-threading first, as it seems you're doing a lot of effort to make sure the second process executes on a separate thread while in general you can just use asynchronous tasks to make sure tasks are executed in parallel.  When you start a sub-process with wait for completion set to false, it will then start the sub-process and execute it until it reaches a wait state (which could be an asynchronous task, a timer node as you specified or even the end of the process).

           

          It would be possible to execute a sub-process completely independent using a new thread as well if you don't require synchronisation.  It wouldn't be too difficult to implement this as a domain-specific service, where your handler would just call startProcess using a new Thread.

           

          Regarding the timers property, this is available in the editor as it was supported in an older version.  The new BPMN2 language however has different constructs for modeling this type of behavior, like timer event, possibly as a boundary event, so it is not supported if you use BPMN2 as the underlying language.  That's also why it's not described in the documentation.

           

          Kris

          1 of 1 people found this helpful