/** * Asserts that the first asyncable task in the given model is indeed asynchronous. Only asserts when the configuration is set to true. * * @param bpmnModel The BPMN model */ private void assertFirstTaskIsAsync(BpmnModel bpmnModel) { if (Boolean.TRUE.equals(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_JOB_DEFINITION_ASSERT_ASYNC, Boolean.class))) { Process process = bpmnModel.getMainProcess(); for (StartEvent startEvent : process.findFlowElementsOfType(StartEvent.class)) { for (SequenceFlow sequenceFlow : startEvent.getOutgoingFlows()) { String targetRef = sequenceFlow.getTargetRef(); FlowElement targetFlowElement = process.getFlowElement(targetRef); if (targetFlowElement instanceof Activity) { Assert.isTrue(((Activity) targetFlowElement).isAsynchronous(), "Element with id \"" + targetRef + "\" must be set to activiti:async=true. All tasks which start the workflow must be asynchronous to prevent certain undesired " + "transactional behavior, such as records of workflow not being saved on errors. Please refer to Activiti and herd documentations " + "for details."); } } } } }
/** * Asserts that the first asyncable task in the given model is indeed asynchronous. Only asserts when the configuration is set to true. * * @param bpmnModel The BPMN model */ private void assertFirstTaskIsAsync(BpmnModel bpmnModel) { if (Boolean.TRUE.equals(configurationHelper.getProperty(ConfigurationValue.ACTIVITI_JOB_DEFINITION_ASSERT_ASYNC, Boolean.class))) { Process process = bpmnModel.getMainProcess(); for (StartEvent startEvent : process.findFlowElementsOfType(StartEvent.class)) { for (SequenceFlow sequenceFlow : startEvent.getOutgoingFlows()) { String targetRef = sequenceFlow.getTargetRef(); FlowElement targetFlowElement = process.getFlowElement(targetRef); if (targetFlowElement instanceof Activity) { Assert.isTrue(((Activity) targetFlowElement).isAsynchronous(), "Element with id \"" + targetRef + "\" must be set to activiti:async=true. All tasks which start the workflow must be asynchronous to prevent certain undesired " + "transactional behavior, such as records of workflow not being saved on errors. Please refer to Activiti and herd documentations " + "for details."); } } } } }