Hello @Ingo_Richtsmeier ,
Is it possible to have multiple ProcessEnginePlugin configuration classes, and choose which one to use when starting a process from the RuntimeService (java)?
Right now I am starting a process using Springboot in the following way:
...
RuntimeService runtimeService = ProcessEngines.getDefaultProcessEngine().getRuntimeService();
ProcessInstanceWithVariables process;
process = runtimeService.createProcessInstanceByKey(processKey).execute()
...
I have two plugin classes, one which sets all bpmn elements to asyncBefore = false, and one which sets asyncBefore = true. Below is the code:
@Component
@Order(Ordering.DEFAULT_ORDER + 1)
@Slf4j
public class DefaultPlugin extends AbstractProcessEnginePlugin {
@Override
public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
if (preParseListeners == null) {
preParseListeners = new ArrayList<>();
processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
}
preParseListeners.add(new Default());
}
}
@Slf4j
public class Default extends AbstractBpmnParseListener {
@Override
public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) {
startEventActivity.setAsyncBefore(false);
}
}
and the second plugin wich sets AsyncBefore = true:
@Component
@Order(Ordering.DEFAULT_ORDER + 2)
@Slf4j
public class AsyncBeforeStartListenerPlugin extends AbstractProcessEnginePlugin {
@Override
public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
List<BpmnParseListener> preParseListeners = processEngineConfiguration.getCustomPreBPMNParseListeners();
if (preParseListeners == null) {
preParseListeners = new ArrayList<>();
processEngineConfiguration.setCustomPreBPMNParseListeners(preParseListeners);
}
preParseListeners.add(new AsyncBeforeStartListener());
}
}
@Slf4j
public class AsyncBeforeStartListener extends AbstractBpmnParseListener {
@Override
public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) {
startEventActivity.setAsyncBefore(true);
}
}