I have 2 workflow.
I want to write workflow if workflow. Thus I want to know how to
- Launch 2 workflow in parallel
- Launch second workflow after first workflow termination
You can achieve this by having multiple workflow launchers, though you have to be careful what these workflows do to the workload, e.g. if they would concurrently change the same property.
There are multiple ways to do this:
Either write a property in the last step of the first workflow and have the second workflow be triggered with a launcher if this property is set. Or you can start another workflow from a custom step:
protected void processItem(WorkItem item, WorkflowSession wfSession, WorkflowData workflowData, String config) throws WorkflowException {
String wfId = "myWorkflowId";
WorkflowModel model = wfSession.getModel(wfId);
wfSession.startWorkflow(model, workflowData);
//optionaly terminate the current workflow programmatically
wfSession.terminateWorkflow(item.getWorkflow());
}