title: Activiti: how to stop the process
body: <p><em><strong>What I want:</em></strong></p>
  
  <p><em><strong>I want to stop Activiti process</em></strong>. For example, I need to restart my server, so I want to stop all activities and then start them again.</p>
  
  <p><em><strong>What I do:</em></strong></p>
  
  <p>Suspend all active activities with the code below:</p>
  
  <pre><code>for (ProcessInstance processInstance : runtumeService.createProcessInstanceQuery().active().list)
    runtimeService.suspendProcessInstanceById(processInstance.getProcessInstanceId())
  </code></pre>
  
  <p><em><strong>What the problems:</em></strong></p>
  
  <p>I have two problems:</p>
  
  <ol>
  <li><em><strong>Suspend doesn't work for tasks in an active state.</em></strong> Moreover, seems that it isn't work even if process hasn't any task in a active state.</li>
  <li><em><strong>ActivitiOptimisticLockingException.</em></strong> It is thrown each time I suspend the process when it has active (in progress) service task.</li>
  </ol>
  
  <p><em><strong>What a question:</em></strong></p>
  
  <p>How to resolve the problems above</p>
  
  <p><em><strong>P.S.</em></strong></p>
  
  <p>To clearify an issue I can provide you more details, more code examples or even a very simple demo  which illustrate the problem. If something isn't clear enough - ask, you are welcome! </p>