How to set conditions for an exclusive BPMN2 gateway

I am using Camunda BPMN2 for the first time in my spring project and trying to figure out a couple of things ...

In my Context app, I have the following block to configure 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 />

I installed two services:

@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(">>>>>>>>>>>>>>>>>>>");      
    }
}

and

@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(">>>>>>>>>>>>>>>>>>>");
    }
}

In scenario 1, I have a parallel gateway that calls both Service1 and Service2 (I built these diagrams using the BPMN2 editor in eclipse):

scenario 1

scenario 1 - service 1

scenario 1 - service 2

Running this line of code:

runtimeService.startProcessInstanceByKey("ConnectorSwitch");

Prints out

>>>>>>>>>>>>>>>>>>>
SERVICE1
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
SERVICE2
>>>>>>>>>>>>>>>>>>>

as was expected.

Now I'm trying to install an exclusive gateway:

enter image description here

Running it gives me the following exception:

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.

+4
1

camunda , . "" "". "". JUEL, , . spring beans , , . , myClass spring bean, ${myClass.doSomethingWithParams(someparam)}. , . "someparam" , . → , . . , , ${true} ${false}. , - . !: -)

+10

All Articles