I'm trying to figure out how to stop the current path of execution, and start at the point of a triggered event.
For example, I have a chain of emails to be sent (2 emails, each seperated by a 3 day timer) asking someone to perform an action which will trigger an event. If they perform the event, then the 2nd email doesn't need to be sent (no reason since they already did what was asked). If they don't reply to either email, then there would be further rules to deal with that.
Basically I have:
Two emails will be sent (ignore the first timer), after which a human task must occur. If they read the emails and perform either of the two tasks below, then that path of action should be followed.
Right now if during one the of the timers an event occurs, that path of execution fires in parallel with the first path. Is there a way to halt execution in the first path and just continue in the 2nd based on an event trigger?
Thanks for any help!
You can simply add some variables to the process (unless you have some facts in your knowledge session that you can access within the process) and initialise them according to the state you are in, then use exclusive gateways by checking their values and act accordingly.
For example in your case add a boolean variable to your process i.e. emailWorkDone, with initial value false. Then if the 2nd path is started and completed based on your business logic then you can make the variable true and by adding a gateway between each timer and sendemail you can decide whether to send another email, by checking the variable, or go to the human task or something else....
have you thought about using sub process and interrupting catch event? I mean that you could create sub process that will enclose timer, send email activities in a loop with a condition to execute the loop for maximum three times (or whatever is your requirement) and then attach to the sub process an interrupting boundary event (signal for instance) that will stop the sub process and continue alternative path.
Maciej what you describe sounds really interesting! I know i might be asking too much but i would greatly appreciate if you could provide a rough/draft bpmn of what you describe. Also i wonder whether it is possible to design such bpmn on any of the designers.... anyhow it would be great if you could show such a bpmn. Thanks
Chris, sure thing I will try ot create such process as soon as I wil be back from my business trio because I do not have my development environment. Hopefully by the end of the weekend.
I think that Eclipse BPMN2 plugin (the new one) is capable of creating such process but I would give a try to web designer as well.
Maciej: I tried using a sub-process for the email sections (email sections would always be comprised of emails & timers, but I wasn't able to get the event to interrupt the process flow in the sub-process. (It'd keep sending emails & waiting). I tried using some of the examples as a guide (BPMN2-EscalationBoundaryEvent.bpmn2 for example), but I wasn't able to get it working properly.
Chris: Do you have any examples of this? I'm still a little weak in my understanding of processInstance variables, I'm not sure what the right way to implement a solution like this might be.
My (somewhat crude) solution was to make an event based diverging gateway that links to a copy of each event for each timer (since the timer is waiting for the event to happen). Then all events converge and move through that path of execution. This way if the event happens then the process goes that way, if the timer expires before the event, then the original path is taken. It feels rather in-elegant, but it does seem to work properly in my testing.
User Task is the action to take if an event never happens, Script is the action to take if one of the events happens:
If i have understood correctly your case, please take a look at the attached bpmn for a possible approach. It is not a fully working example.... just showing the concept.
So the idea is,
1. you send email to some user to do some job
2. you start the timer, to give time to the user to do the job before sending next email
3. you check if the user has done the job. This check is done by checking if the process variable jobDone has been set to true
4. if it is set, in other words if the job is done, then go down to the process for running script and ending the process
5. if the job is not done then send another email and wait for some time
6. check again if the job has been done ....
7. if not do the human task and end the process
testWithEmails.bpmn.zip 1.8 K
Finally found some time to take a try with what I described, so the process would look something like this (it does not address all the requirements but just illustrates how it could be used):
Process was drawn in BPMN2 eclipse plugin so most of it was possible but few elements, like timer duration, need to be done directly on xml.
I have managed to run the example and it was interupting the sub process when signalled so it seems like it could be rather nice alternative to more complex options given above.
Unfortunately signal event is not implemented for boundary events, small modification to jBPM code is required.
Please find attached complete bpmn definition for reference.
subprocess.bpmn2.zip 1.6 K
Thanks Maciej this looks nice and efficient.
I would also like to add that based on this and the approach i proposed earlier, in order to support arbitrary number of email sendings, the following could be done, which works on eclipse editor and jbpm with no modifications.
The same as before just using an embedded sub process and introduced two more process variables, loopIterations and loopCount.
testWithEmails2.bpmn.zip 2.1 K
Thanks guys for all the feedback, especially the excellent examples.
I'm going to try out a blending of both approaches, similar to Chris' Oct 24th post.
One last question for Maciej: You mentioned signal event isn't implemented for boundary events, did you use the signalEventDefinition in your example just to illustrate how it would look once JBPM (assuming it will) implements a signal event for boundary events?
Thanks again for all the info!