Я впервые использую Camunda BPMN2 в своем весеннем проекте и пытаюсь понять пару вещей...
В моем applicationContext у меня есть следующий блок для настройки Camunda:
<!-- Setup BPMN Process Engine -->
<bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration">
<property name="processEngineName" value="engine" />
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager" />
<property name="databaseSchemaUpdate" value="true" />
<property name="jobExecutorActivate" value="false" />
<property name="deploymentResources" value="classpath*:*.bpmn" />
</bean>
<bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean">
<property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>
<bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
<bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
<bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
<bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />
<context:annotation-config />
Я настроил две службы:
@Component(value="service1")
public class Service1 implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
System.out.println(">>>>>>>>>>>>>>>>>>>");
System.out.println("SERVICE1");
System.out.println(">>>>>>>>>>>>>>>>>>>");
}
}
а также
@Component(value="service2")
public class Service2 implements JavaDelegate {
@Override
public void execute(DelegateExecution execution) throws Exception {
System.out.println(">>>>>>>>>>>>>>>>>>>");
System.out.println("SERVICE2");
System.out.println(">>>>>>>>>>>>>>>>>>>");
}
}
В сценарии 1 у меня есть параллельный шлюз, который вызывает как Service1, так и Service2 (я построил эти диаграммы с помощью редактора BPMN2 в eclipse):
Запуск этой строки кода:
runtimeService.startProcessInstanceByKey("ConnectorSwitch");
Распечатывает
>>>>>>>>>>>>>>>>>>>
SERVICE1
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
SERVICE2
>>>>>>>>>>>>>>>>>>>
как и ожидалось.
Теперь я пытаюсь установить эксклюзивный шлюз:
Запуск дает мне следующее исключение:
SEVERE: Error while closing command context
org.camunda.bpm.engine.ProcessEngineException: Exclusive Gateway 'ExclusiveGateway_3' has outgoing sequence flow 'SequenceFlow_39' without condition which is not the default flow. | ..../ConnectorSwitch.bpmn | line 0 | column 0
Exclusive Gateway 'ExclusiveGateway_3' has outgoing sequence flow 'SequenceFlow_40' without condition which is not the default flow. | ..../ConnectorSwitch.bpmn | line 0 | column 0
at org.camunda.bpm.engine.impl.util.xml.Parse.throwExceptionForErrors(Parse.java:183)
at org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse.execute(BpmnParse.java:177)
at org.camunda.bpm.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:106)
at org.camunda.bpm.engine.impl.persistence.deploy.DeploymentCache.deploy(DeploymentCache.java:50)
at org.camunda.bpm.engine.impl.persistence.entity.DeploymentManager.insertDeployment(DeploymentManager.java:42)
at org.camunda.bpm.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:81)
at org.camunda.bpm.engine.impl.cmd.DeployCmd.execute(DeployCmd.java:50)
at org.camunda.bpm.engine.impl.interceptor.CommandExecutorImpl.execute(CommandExecutorImpl.java:24)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:90)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)
......
Исключение довольно ясное, мне не хватает условия на Exclusive Gateway. Итак, мой вопрос: как мне назначить условие для эксклюзивного шлюза, как мне вызвать метод в определенном классе и оценить true/false, и если я хочу вызвать что-то еще, что не является JavaDelegate для service1/service2 ( другими словами, MyClass.doSomethingWithParams(someparam)), как мне это сделать?
Ответы в XML также хороши, я бы предпочел научиться использовать BPMN2 в XML вместо того, чтобы полагаться на визуальные эффекты BPMN2.