How to terminate active sub process

I have a parent workflow using call activity it invokes sub process in parallel.
i want to terminate any active on going sub process without executing further if any other sub process throws error event.

the way i have designed, i see if any one of the workflow throws error event, it will be catched by the parent process and process will end.
But other active sub process still executes at the end of the processes they will due to optimistic locking exception
Is there any other way so that sub process should not be waiting till end of the process and terminate as soon as any other sub flow throws error event

Thanks in Advance

Hi @gowtham_m , you can try like below.

BPMN File: OrderProcessDemoCallActivity.bpmn (14.9 KB)

@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"));
		log.info("Dataformat name:{}", spinJsonNode.getDataFormatName());
		List<String> ordersList = spinJsonNode.mapTo(List.class);
		execution.setVariable("ordersList", ordersList);
		log.info(
				"ordersList:{}\n MultiInstance Properties:nrOfActiveInstances{}\nnrOfCompletedInstances:{}\nnrOfInstances:{}",
				ordersList, execution.getVariable("nrOfActiveInstances"),
				execution.getVariable("nrOfCompletedInstances:"), execution.getVariable("nrOfInstances"));
		
		if(execution.hasVariable("isValidOrder") && !(Boolean)execution.getVariable("isValidOrder")) {
			log.info("Error code:{}",execution.getVariable("errorCode"));
			throw new BpmnError("UN_PROCESSABLE_ORDER_ERR", "Invalid order request recieved");
		}
	}

}

@Slf4j
@Component
public class LoggerDelegate implements JavaDelegate {

	@Override
	public void execute(DelegateExecution execution) throws Exception {
		log.info("Logging for activity: {}\n, ErrorCode: {}, ErrorMessage: {}",
				execution.getCurrentActivityName(), execution.getVariable("errorCode"),
				execution.getVariable("errorMessage"));

	}

}

Process instance start request:

{
  "variables": {
    "orderItems" : {
        "value" : "[\"Order1\",\"Order2\"]",
        "type": "Json"
    }
  },
 "businessKey" : "Order-489086"
}

When the “Approve order” task created, deselect it. It will be considered as rejected and then the bpmn error event will be thrown and the entire process will be terminated along with sub process too.


@aravindhrs hi arvindh, thanks but above one will terminate only that particular sub workflows right not other active sub workflows . Let us assume it has only service delegates no human task at pending. How can I terminate other active sub process which is executing

It terminates all the subprocess, because terminate end event is used followed by the error catch boundary event

@aravindhrs i have tried the same, i am throwing error from sub workflow, catched by error boundary event on call activity, and terminated.
But Still i see other active sub workflows is still active and executing and only terminates when it reaches end event

Can you upload your bpmn file?

True.