During development we stumbled upon a following problem:
We try to download data from external database.
1. We want to download data but not all at once! Let's say we Are downloading sales data grouped by product name
2. We want to perform downloading process for each product separately, therefore we do the following:
a) we create 'for each' iteration loop that goes "by product"
b) in the loop we run the operation process that downloads data for the given product.
Because the processes are asynchronous, loop does not wait for the end of the process, it initiates another one! Because of that connection to the external DB is swarmed with requests of processes and soon dies out. Is there any way to make the loop wait for the process to finish?
We can (and probably will) add some kind of semaphore, but is there any other way?
As far as I can understand, you want to fetch a product, then use a process to do something with that product related records. And you want to do this for all products you have and waiting for the processing of one product to end to start all over again with the next product (fetch product related rows and execute the process).
A solution I came up (I don't if it is the better one), in the action after you place the "Lauch Process" node you should have a "mutex". That mutex should wait for the processs to end to release the flow:
I don't know if this solves your problem entirely but I hope it can help you.
This is pretty much the same solution we thought about ourselves, we were just hoping that there is some kind of built-in mechanism.
Good to know "we are not the only one" ;)
Thomas solution is indeed possible and serves the purpose of running processes sequentially.
I would propose a different solution to better take advantage of the BPT engine and avoid having "sleeps" in your action/timer, which will make it take as long to run as the time all processes take. Check the module attached for an implementation example.
In my solution you have a "parent" process that takes care of executing the "child" processes (which fetch data for each product) and use a Wait activity to do the same thing as the "sleep" but all in a controlled fashion. You also have the advantage that the parent process only finishes when all child processes finish, so if you want to know whether all products are done or not (or monitor the time the full operation takes), you can just check the parent process.
All the processing and waiting is done in the BPT engine (no action/timer execution pending) and can be monitored easily using "Process Monitoring" screen in Service Center.
Hope it helps!