Modeling call activity for a use case

Hi,

I use call activity to create multiple subprocesses on another BPMN. I always create 3 subprocesses for a parent process.

This is my main workflow. If I need multiple items to check and approve, I handle it via call activity.

Inside call activity, while waiting for client approval, the client can keep existing items and request more items to make decisions. At this time, I need to create 3 more subprocesses for the same parent process. So that the parent process can have 3,6,9,12 or more subprocess if needed. Call activity’s BPMN is below.

Can you give me any idea about how can I do this? I think I need to do this outside of call activity’s BPMN because requesting more items is not related to any existing subprocess, is related to their parent.

@serhat refer the below post, it might help you.

Hi @aravindhrs ,

Thanks for your response. I think this post is about submitting multiple subprocesses at the same time. My case might be a bit different. I submit 3 subprocesses. When these 3 subprocesses arrive at a certain task (waiting for approval) in call activity’s BPMN, the client can request more items. Then I need to submit 3 more for the same parent. This is the approach that I just created using a parallel gateway. Initially, I create 3 subprocesses and also start waiting for another message in case the client requests more. If the client requests more items, I create 3 more subprocesses and also go back to the ‘waiting for the client to request more items’ task in case of the client request more.

I am not sure if it is the best approach. I keep waiting for the client to request more items and I complete call activity if one of the subprocesses is completed.

@serhat , You can refer the below example.

BPMN File: OrderProcessDemo.bpmn (12.1 KB)

Code:

@Slf4j
@Component("orderProcessDelegate")
public class OrderProcessDelegate implements JavaDelegate {

	@SuppressWarnings("unchecked")
	@Override
	public void execute(DelegateExecution execution) throws Exception {
		log.info("Processing OrderProcessDelegate for businessKey: {}", execution.getProcessBusinessKey());
		SpinJsonNode spinJsonNode = Spin.JSON(execution.getVariable("orderItems"));
		List<String> ordersList = spinJsonNode.mapTo(List.class);
		execution.setVariable("ordersList", ordersList);
		log.info("ordersList:{}", ordersList);
	}

}

Post request to start a instance:

curl --location --request POST 'http://localhost:8080/engine-rest/process-definition/key/OrderProcessDemo/start' \
--header 'Authorization: Basic ZGVtbzpkZW1v' \
--header 'Content-Type: application/json' \
--data-raw '{
  "variables": {
    "orderItems" : {
        "value" : "[\"MacBookPro\",\"Acer Predator\",\"Nvidia GeForce\"]",
        "type": "Json"
    }
  },
 "businessKey" : "Order-100"
}'

Correlate message to create start few more sub-processes:

curl --location --request POST 'http://localhost:8080/engine-rest/message' \
--header 'Authorization: Basic ZGVtbzpkZW1v' \
--header 'Content-Type: application/json' \
--data-raw '{
    "messageName": "APPEND_ORDER",
    "processVariables": {
        "orderItems": {
            "value": "[\"MacBookPro\",\"Acer Predator\",\"Dell\"]",
            "type": "Json"
        }
    }
}'

2 Likes

That is what i need. Thank you so much @aravindhrs

1 Like

Hi,

I have another question. I expect the process to finish if I complete one sub-process. Let’s say, I created 3 subprocesses only one time and completed it without requesting more items. The completion condition works fine and completes the sub-process.
${nrOfCompletedInstances/nrOfInstances >= 0.3}

But if I add 3 more items, then I get duplicate nrOfInstances and nrOfCompletedInstances variables on the parent process. So the below condition doesn’t work for me.

${nrOfCompletedInstances/nrOfInstances >= 0.01}

All 6 subprocesses have the same superProcessInstanceId. I expect 6 of them to complete but only 3 of them get completed and the parent process keeps waiting.

Any idea about how to overcome this scenario? Do I need to manually delete other subprocesses if I complete one? @aravindhrs

I couldn’t find any solution to this problem. As a workaround, I will try to avoid revisiting call activity to add new subprocesses for the same parent. In the beginning, I will create a possible maximum amount of subprocesses. E.g Loop cardinality will be set to 15 instead of 3. So that I will create them only one time and I won’t have duplicate nrOfCompletedInstances, nrOfInstances variables on the parent process… And I will set the completion condition.