title: How to setup conditionals for BPMN2 Exclusive Gateway
body: <p>I'm using Camunda BPMN2 for the first time in my spring project and trying to get my head around a couple of things ...</p>
  
  <p>In my applicationContext, I have the following block to setup Camunda:</p>
  
  <pre><code>    &lt;!-- Setup BPMN Process Engine --&gt;
      &lt;bean id="processEngineConfiguration" class="org.camunda.bpm.engine.spring.SpringProcessEngineConfiguration"&gt;
          &lt;property name="processEngineName" value="engine" /&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="transactionManager" ref="transactionManager" /&gt;
          &lt;property name="databaseSchemaUpdate" value="true" /&gt;
          &lt;property name="jobExecutorActivate" value="false" /&gt;
          &lt;property name="deploymentResources" value="classpath*:*.bpmn" /&gt;
      &lt;/bean&gt;
      &lt;bean id="processEngine" class="org.camunda.bpm.engine.spring.ProcessEngineFactoryBean"&gt;
          &lt;property name="processEngineConfiguration" ref="processEngineConfiguration" /&gt;
      &lt;/bean&gt;
      &lt;bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" /&gt;
      &lt;bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" /&gt;
      &lt;bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" /&gt;
      &lt;bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" /&gt;
      &lt;bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" /&gt;
      &lt;context:annotation-config /&gt;
  </code></pre>
  
  <p>I've setup two services:</p>
  
  <pre><code>@Component(value="service1")
  public class Service1 implements JavaDelegate {
      @Override
      public void execute(DelegateExecution execution) throws Exception {     
          System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");
          System.out.println("SERVICE1");     
          System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");      
      }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>@Component(value="service2")
  public class Service2 implements JavaDelegate {
      @Override
      public void execute(DelegateExecution execution) throws Exception {
          System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");
          System.out.println("SERVICE2");     
          System.out.println("&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;");
      }
  }
  </code></pre>
  
  <p>In scenario 1 I have a parallel gateway that calls both Service1 and Service2 (I've built these diagrams using BPMN2 editor in eclipse):</p>
  
  <p><img src="https://i.stack.imgur.com/7707I.png" alt="scenario 1"></p>
  
  <p><img src="https://i.stack.imgur.com/gLiJB.png" alt="scenario 1 - service 1"></p>
  
  <p><img src="https://i.stack.imgur.com/eWYDP.png" alt="scenario 1 - service 2"></p>
  
  <p>Running this line of code:</p>
  
  <pre><code>runtimeService.startProcessInstanceByKey("ConnectorSwitch");
  </code></pre>
  
  <p>Prints out </p>
  
  <pre><code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
  SERVICE1
  &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
  &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
  SERVICE2
  &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
  </code></pre>
  
  <p>as expected.</p>
  
  <p>Now I'm trying to put in an Exclusive Gateway:</p>
  
  <p><img src="https://i.stack.imgur.com/fbVoF.png" alt="enter image description here"></p>
  
  <p>Running it gives me the following exception:</p>
  
  <pre><code>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) 
      ......
  </code></pre>
  
  <p>The exception is pretty clear, I'm missing a condition on the Exclusive Gateway.
  So my question is, how do I assign a condition to the exclusive gateway, how do I call a method in a certain class and evaluate the true / false and if I want to call something else that is not a JavaDelegate for service1 / service2 (in other words, MyClass.doSomethingWithParams(someparam)), how would I go about that?</p>
  
  <p>Answers in XML is fine as well, would prefer to learn how to use BPMN2 in XML instead of relying on the BPMN2 visuals.</p>