Suspend and resume processinstance based on runtime conditions

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2016 11:15 AM
In my process, I need to make a call to an external service. I know that this service requires 4 (non-null) values to be passed to it, let's say A, B, C, D. It is possible that these 4 values may be already available as (non-null) process variables. On the other hand, sometimes, some of these may be null.
To make things easier for the business user I plan to use the Single Service Task approach mentioned in the article at http://long-running.net/blog/2015/should-asynchronous-service-invocations-be-visible-in-a-bpmn-diagr... and the Req/Acl/Callback pattern.
This works great with the assumption A, B, C, D are present, while using a class that extends AbstractBpmnActivityBehavior, but I need the following additional functionality:
To make things easier for the business user I plan to use the Single Service Task approach mentioned in the article at http://long-running.net/blog/2015/should-asynchronous-service-invocations-be-visible-in-a-bpmn-diagr... and the Req/Acl/Callback pattern.
This works great with the assumption A, B, C, D are present, while using a class that extends AbstractBpmnActivityBehavior, but I need the following additional functionality:
- If either of the parameters A, B, C, D are null, pause the processinstance, and create a task for the user that will ask for the null params.
- Once the params are provided in the task, the processinstance resumes its execution with all values, makes a service call, and waits for the callback to be called.
Question: can this even be done? If yes, any pointers please…
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2016 02:34 AM
Hi,
Regards
Martin
If either of the parameters A, B, C, D are null, pause the processinstance, and create a task for the user that will ask for the null params.Yes, use exclusive gateway with conditional flow.
Once the params are provided in the task, the processinstance resumes its execution with all values, makes a service call, and waits for the callback to be called.Put this logic after the conditional flow and user task.
Regards
Martin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2016 02:41 AM
Hi Martin,
I'm using that approach already, but it entails 2 extra elements (X-GW, HT) in the flow, and 'leaks the abstraction' to the business user.
I was looking to make this a sort of 'smart activity' (read: one single box for the b.u.) , that 'knows' whether it can perform the service, and if not, wait till all the data is available to try again.
Basically, once the execution enters an activity, if it can successfully perform the service call, does it, else suspends self, till it receives a signal with the 'missing data', and then performs the service call.
The pseudocode would be somewhat like below:
[java]
public void execute(){
boolean allDataPresent = checkAllData();
if(allDataPresent){
call service;
}
else {
create task to getAllData;
}
}
public void signal(…){
if(serviceCompletedSignal){
add signalData to procVars;
leave();
}
else{//allData is available signal
add allData to procVars;
execute();
}
}
[/java]
Question is : Does this approach make sense in the process engine world?
Thanks
Rajiv
I'm using that approach already, but it entails 2 extra elements (X-GW, HT) in the flow, and 'leaks the abstraction' to the business user.
I was looking to make this a sort of 'smart activity' (read: one single box for the b.u.) , that 'knows' whether it can perform the service, and if not, wait till all the data is available to try again.
Basically, once the execution enters an activity, if it can successfully perform the service call, does it, else suspends self, till it receives a signal with the 'missing data', and then performs the service call.
The pseudocode would be somewhat like below:
[java]
public void execute(){
boolean allDataPresent = checkAllData();
if(allDataPresent){
call service;
}
else {
create task to getAllData;
}
}
public void signal(…){
if(serviceCompletedSignal){
add signalData to procVars;
leave();
}
else{//allData is available signal
add allData to procVars;
execute();
}
}
[/java]
Question is : Does this approach make sense in the process engine world?
Thanks
Rajiv
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-12-2016 07:45 AM
It does, you can pretty much do what you in an ActivityBehaviour. I've also used a similar approach in the past (logic + custom wait combined)
