Synchronous execution of a bpmn

Hello, I’m trying to execute a bpmn in a synchronous way to get the result of the execution at the end and send it, but I don’t know if there is any way using camunda

public void executeBPMSync(String bpmName, Map<String, Object> parameters) throws OrcaException {

    		try {
                      // I need the run this in a synchronous way
    			runtimeService.startProcessInstanceByKey(bpmName, variables);
    		} catch (ProcessEngineException e) {
    			LOGGER.error("Error starting process instance", e);
    			throw new OrcaException(OrcaErrorMessages.BPM_EXECUTION_ERR, bpmName);

is there anyone already had an example like this? Thank you

@Boubaker_Idir While designing a bpmn model don’t mark any of the activity as asyncBefore:true & asyncAfter:true, this will execute in a synchronous way by default.

Hi @Boubaker_Idir,

you can start the process instance with ProcessInstanceWithVariables processInstanceWithVariables = runtimeService.createProcessInstanceByKey(bpmName).setVariables(parameters).executeWithVariablesInReturn();.

Hope this helps, Ingo

1 Like