We still don't have a "dynamic" gateway in ES2.
However if your goal is to send it to a bunch of people in parallel, you can use the Assign Multiple Task. This allows you to send a task to multiple people and consolidate the result.
Would that work?
Hi Jasmin, thanks for your reply.
Actually I want to send pdf attached emails to people outside the organization. I can solved this part of the problem with a loop. But now, I need to know how can I handle responses. I want to get all responses and merge them into a form. But I dont know how to wait for each respond? For example I sent 3 email and to proceed process, I need to wait for each response. Do you have any suggestion?
That's not easy to do because the receiving process is really independent from the process that sends the three emails. At least, I think it should.
One way to approach it it to create a receiving process with an email endpoint. This process will be responsible to receive all emails that were sent for all requests. Maybe there was a request (A) that sent three emails out and another request (B) that sent 2 emails out.
Now when you receive the emails back, you would have to maintain the state of your requests in some ways. I suggest you create a database tables to keep track of the number of emails per request. The unique identifier for the request could be the process instance id from the main process since it'll be the same for every emails in a particular request.
When they come back, you can update the db and check if you have received all emails. If not, then you terminate and continue waiting for the next one. When you get them all, you call a process that generates the form.
Does that make sense?
I have solved the problem as you suggested. When I find an appropriate time I will post solution to my blog.
Also thanks to Steve for his explanatory post.
I created what you are referring to as a dynamic Gateway. I have had it in production for years over multiple versions. I used a No-wait gateway in a loop and an event to capture when all the threads were completed. A problem I ran into was race conditions. If the Gateway had steps A, B, C and I had two thread 1 and 2. I did not always get A1, B1, C1, A2, B2, C2. If 2 users completed a task within a couple seconds of each other, I got A1, A2, B1, B2, C1, C2. This resulted in data corruption. One of the things I did was to get rid of the Gateway and replace it with no-wait sub process. I pass the process ID of the main process over and use it in the event throw/catch. To address the approval race condition, I put everything steps A, B and C did into an Execute Script step. At the start of the step, I did a JDBC/SQL select for update on the database row for the main process on a variable/column that is not used for anything else except for the lock. A secondary benefit is the processing is much faster. I don't know if this changed in ES2, but in ES1, you could not tell from an error which line of a set value was causing the issue. If you do the same thing in an Execute Script, you get the line number in the error message.
To do something similar with emails, I would make it so the returning emails kick off a process. Store the process ID of the original process in the data of the form. Use that to throw an event back to the originating process.