<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Running parallel tasks with acitiviti in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88888#M60356</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the post. This works but I have another problem. I am running activiti as a standalone application which is forked off using a command line. Now the problem with async=true is that, my program exits as soon as the activiti process is started. Is there a way to block until the whole process is done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can work around this problem by starting it in a thread and waiting till the process moves to the history but it would be great if i can get an api or more robust solution/way of doing it.?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Rakesh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Jun 2012 06:28:14 GMT</pubDate>
    <dc:creator>hellowrakesh123</dc:creator>
    <dc:date>2012-06-20T06:28:14Z</dc:date>
    <item>
      <title>Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88886#M60354</link>
      <description>Hi,I am new with Activiti and trying to get the parallel gateways work but i couldn't get it working the way I was expecting. Am I doing something wrong here?I have 2 tasks Build-1 and Build-2, I want to fork off the 2 tasks at the same time as soon as the workflow starts.When i am running the workf</description>
      <pubDate>Sun, 17 Jun 2012 00:25:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88886#M60354</guid>
      <dc:creator>hellowrakesh123</dc:creator>
      <dc:date>2012-06-17T00:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88887#M60355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It seems like you can't to have the 2 service-tasks being executed in parallel?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The parallel gateway in BPMN indicates the path of execution splits into several paths. Dis doesn't necessarily mean they should be executed by different threads. When you call the startProcessInstance(), the calling thread will execute the workflow until a wait state is reached. When reaching a parallel gateway, there are two "concurrent execution paths" created and each of them is executed until it reaches a wait state/end or parallel join. This is done by THE SAME THREAD, so the paths are executed sequentially internally. However, when the startProcessInstance() returns, all parallel executions are executed and waiting/finished. So they are actually executed in parallel in the same API-call but not parallel as in multi-threaded.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to execute the 2 service-tasks in parallel, they should both have "async=true".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 08:02:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88887#M60355</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-18T08:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88888#M60356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the post. This works but I have another problem. I am running activiti as a standalone application which is forked off using a command line. Now the problem with async=true is that, my program exits as soon as the activiti process is started. Is there a way to block until the whole process is done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can work around this problem by starting it in a thread and waiting till the process moves to the history but it would be great if i can get an api or more robust solution/way of doing it.?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Rakesh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 06:28:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88888#M60356</guid>
      <dc:creator>hellowrakesh123</dc:creator>
      <dc:date>2012-06-20T06:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88889#M60357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Most of the time, your application will run in some kind of environment (web server, osgi, ..) which is not just a simple main-thread and creates at least one non-deamon thread that keeps the app alive. You should google for solutions around this, it's a common java question.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 07:04:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88889#M60357</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-20T07:04:39Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88890#M60358</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried running the same application in tomcat but still can't get the acitiviti:async="true" working. Here is the bpm definition I have, when i set acitiviti:async="true", nothing gets executed, when i remove acitiviti:async="true", it gets executed but all in sequential order. Am i missing something here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&amp;lt;definitions xmlns="&lt;A href="http://www.omg.org/spec/BPMN/20100524/MODEL" rel="nofollow noopener noreferrer"&gt;http://www.omg.org/spec/BPMN/20100524/MODEL&lt;/A&gt;"&lt;BR /&gt; xmlns:activiti="&lt;A href="http://activiti.org/bpmn" rel="nofollow noopener noreferrer"&gt;http://activiti.org/bpmn&lt;/A&gt;" targetNamespace="Examples"&amp;gt;&lt;BR /&gt; &amp;lt;process id="cca-workflow-process" name="cca-workflow-process"&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;documentation&amp;gt;Place documentation for the 'mtrose-bpm-workflow'&lt;BR /&gt;&amp;nbsp;&amp;nbsp; process here.&amp;lt;/documentation&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;startEvent id="startevent1" name="Start"&amp;gt;&amp;lt;/startEvent&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;parallelGateway id="parallelgateway1" name="Parallel Gateway"&amp;gt;&amp;lt;/parallelGateway&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;serviceTask id="build" name="build"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; activiti:class="com.cisco.step.cca.engine.delegate.BuildTaskDelegate" activiti:async="true"&amp;gt;&amp;lt;/serviceTask&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;parallelGateway id="parallelgateway2" name="Parallel Gateway"&amp;gt;&amp;lt;/parallelGateway&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;serviceTask id="hss_sanity_c4" name="hss_sanity_c4"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; activiti:class="com.cisco.step.cca.engine.delegate.SanityTaskDelegate"&amp;gt;&amp;lt;/serviceTask&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;serviceTask id="sa" name="sa"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; activiti:class="com.cisco.step.cca.engine.delegate.StaticAnalysisTaskDelegate"&amp;gt;&amp;lt;/serviceTask&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;serviceTask id="cr" name="cr"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; activiti:class="com.cisco.step.cca.engine.delegate.CodeReviewTaskDelegate" activiti:async="true"&amp;gt;&amp;lt;/serviceTask&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;serviceTask id="ut" name="ut"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; activiti:class="com.cisco.step.cca.engine.delegate.UnitTestTaskDelegate" activiti:async="true"&amp;gt;&amp;lt;/serviceTask&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow1" name="" sourceRef="startevent1"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="parallelgateway1"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;parallelGateway id="parallelgateway3" name="Parallel Gateway"&amp;gt;&amp;lt;/parallelGateway&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;endEvent id="endevent1" name="End"&amp;gt;&amp;lt;/endEvent&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow5" name="" sourceRef="build"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="parallelgateway2"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow6" name="" sourceRef="parallelgateway2"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="hss_sanity_c4"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow7" name="" sourceRef="parallelgateway2"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="sa"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;parallelGateway id="parallelgateway4" name="Parallel Gateway"&amp;gt;&amp;lt;/parallelGateway&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow10" name="" sourceRef="parallelgateway3"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="parallelgateway4"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow11" name="" sourceRef="cr"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="parallelgateway4"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow12" name="" sourceRef="ut"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="parallelgateway4"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow13" name="" sourceRef="parallelgateway4"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="endevent1"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow14" name="" sourceRef="parallelgateway1"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="build"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow15" name="" sourceRef="parallelgateway1"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="cr"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow16" name="" sourceRef="parallelgateway1"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="ut"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;receiveTask id="sanity_response" name="sanity_response" activiti:class="com.cisco.step.cca.engine.delegate.SanityStatusTaskDelegate"&amp;gt;&amp;lt;/receiveTask&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow17" name="" sourceRef="hss_sanity_c4"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="sanity_response"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow18" name="" sourceRef="sanity_response"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="parallelgateway3"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;lt;sequenceFlow id="flow19" name="" sourceRef="sa"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; targetRef="parallelgateway3"&amp;gt;&amp;lt;/sequenceFlow&amp;gt;&lt;BR /&gt; &amp;lt;/process&amp;gt;&lt;BR /&gt;&amp;lt;/definitions&amp;gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;My delegates are implemented using JavaDelegate:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;public class BuildTaskDelegate implements JavaDelegate {&lt;BR /&gt; &lt;BR /&gt; public void execute(DelegateExecution execution) throws Exception {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("before…");&lt;BR /&gt;&amp;nbsp; Process process=Runtime.getRuntime().exec("sleep 10");&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("after…");&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 06:00:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88890#M60358</guid>
      <dc:creator>hellowrakesh123</dc:creator>
      <dc:date>2012-06-22T06:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88891#M60359</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Make sure your job-executor is active. You can verify this by checking your engine-settings. The jobExecutorActivate should be true. Alternatively, you can double-check in code by getting the processEngineConfiguration-object from the ProcessEngine (cast to IMPL may be needed) en call getJobExecutor().isActive().&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 06:35:33 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88891#M60359</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-22T06:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88892#M60360</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ohh so thats the issue, it was set as false, it worked as I changed the jobExecutorActivate=true.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you so much for the help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;May be this is something you might want to add to the documentation where you explained async.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 06:45:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88892#M60360</guid>
      <dc:creator>hellowrakesh123</dc:creator>
      <dc:date>2012-06-22T06:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88893#M60361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad it helped &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The section on the async states the job executor is used for this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;This background thread is the activiti job executor (actually a thread pool) which periodically polls the database for jobs. So behind the scenes, when we reach the "generate invoice" task, we are creating a job "message" for activiti to continue the process later and persisting it into the database. This job is then picked up by the job executor and executed. We are also giving the local job executor a little hint that there is a new job, to improve performance.&lt;BR /&gt;&lt;/CODE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 06:49:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88893#M60361</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-22T06:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88894#M60362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Another issue, although i read about this but how do we handle this (i mean how to make sure it doesn't happen). With async=true and exclusiveJob=false, it is working as expected but now i am seeing exceptions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;org.activiti.engine.ActivitiOptimisticLockingException: ExecutionEntity[4] was updated by another transaction concurrently&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This happens when more than one task tries to update the parallel join nodes. If it fails, it tries again and run the task again. This is undesirable and how should i make sure that it doesn't get executed again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a dirty solution, create one more task in front of each parallel task which doesn't do anything but just passes by to make sure even if it is executed, it doesn't affect anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Rakesh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 06:07:15 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88894#M60362</guid>
      <dc:creator>hellowrakesh123</dc:creator>
      <dc:date>2012-06-26T06:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88895#M60363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When both tasks are "async", they both get acquired by the job-executor at the same time (since it has multiple threads available) and actually executed concurrently. When the two paths reach the join, one of them will get an exception, trying to update the shared execution that forked off the 2 parallel. The job-executor will retry a job for 3 times until it stops.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm afraid this is just how the engine works. Concurrent updates of the same entity in different transactions can't be handled differently, smart merging or updating can cause to stale state or even data-loss so that's not desirable. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What you can do to have minimal effect of this is trying to make sure the service YOU call in the service-task use the same transaction, so the rollback by the failing execution cleans up any work performed. If this is not possible (other DB, non-transactional operations,…) you should consider something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(read full post at &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=4139&amp;amp;p=16108&amp;amp;hilit=exeternal%20thread%20pool" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=4139&amp;amp;p=16108&amp;amp;hilit=exeternal%20thread%20pool&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;LI&gt;The service-task prepares (eg. read variables from process) an creates the "job" or runnable to be executed by the external thread pool&lt;/LI&gt;&lt;LI&gt;Service-task queues the job (saving reference to process-instance id) and finishes&lt;/LI&gt;&lt;LI&gt;Right after the service-taks, there's a receive-task that waits, releasing the calling thead and not holding open the transaction.&lt;/LI&gt;&lt;LI&gt;Long-running operation completes and signals the process-instance and perhaps set some variables on the process based on the results before signaling.&lt;/LI&gt;&lt;BR /&gt;&lt;SPAN&gt;Also interesting info about signaling/jobexecutor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=4138" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=4138&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=4165&amp;amp;hilit=signal" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=4165&amp;amp;hilit=signal&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 07:12:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88895#M60363</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-26T07:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88896#M60364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for the response. I read the threads and have managed to make the workflow work with receive tasks. However, it has invoked a doubt regarding the way workflow will serve, please correct me if my understanding is wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BPMN specification defines parallel workflows which is implemented in Activiti as well. Going over the documentation and suggestions by you, the *real* parallel execution which runs tasks concurrently really isn't there by default due to the reasons mentioned in documentation and by you as well. This means even we express the workflow via parallel gateways it is really sequential. Receive tasks do provide us a way to achieve this but this limits us to use the normal service tasks. So even if the tasks are not really long running but also non db, we have to choose receive task which doesn't look right. Also with receive task, there is a problem if two tasks which run in parallel joins nodes at the same time, it still has locking issue but now we can manually synchronize it to make sure it doesn't hit the issue during signal. So the problem is same but it works using receive tasks because we know when to synchronize which we can't do with normal service task. The way I solve is to lock a common monitor in the thread spawned by the service tasks which signals the receive tasks. I acquire the class lock and makes sure all threads wait for the lock to be acquired before signal.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So here are my few questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Is there is way in service tasks to synchronize using our code (override any method) similar to common monitor.? This will solve the problem with async=true and exclusiveJob=false and allow real parallel paths concurrently.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Isn't it something which activiti/engine should do by default or is there is something i missing to understand how it is implemented.? This is a common problem and going for a workaround using receive tasks doesn't sound very convincing although its a simple solution. The problem with the approach you suggested is that, the first service task is just a dummy tasks which queue the request. The other problem with that approach is the service tasks is required to know the proceeding receive task which means i can't have dynamically created workflows else i will have to put some real code to make service task aware of the proceeding receive task. Infact we can work without service tasks and have the receive task do it extending ReceiveTaskActivityBehavior and starting a thread from it. Is there a specific reason for using service task before receive task or its only for queuing or i am missing anything here.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am looking at all the aspects and trying to understand if i am making the right choice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Rakesh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 05:18:21 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88896#M60364</guid>
      <dc:creator>hellowrakesh123</dc:creator>
      <dc:date>2012-07-02T05:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88897#M60365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I suggest reading this thread, as it's a similar discussion…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=4138&amp;amp;start=20" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=4138&amp;amp;start=20&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 12:10:48 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88897#M60365</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-07-02T12:10:48Z</dc:date>
    </item>
    <item>
      <title>Re: Running parallel tasks with acitiviti</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88898#M60366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;[img]Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I read the discussion and understand the suggestions. My question is more on how to make sure *pure* service task synchronize on a monitor before completing. You mentioned following example to have mutex logic. How can this be implemented in the delegate analogous to signal event in receive tasks. The code you gave requires me to write logic outside my delegate. This will cause me to have flow control logic outside of delegate which will not be scalable in our case. We are dynamically generating the workflow and running it. The few tasks are long running ones where we are using receive tasks and works as we discussed. For the tasks which are not long running and implement using JavaDelegate (another web service call but are non-db transactional i.e. can't be rolled back), having parallel gateway causes tasks to be re-executed with OptimisticLockException. I want to make sure when they join, i implicitly synchronize complete() on a common monitor either in delegate or somewhere which is generic for all JavaDelegates and can use async=true and exclusiveJob=false for concurrent tasks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So my requirement is simple, i have set of parallel tasks and dynamic workflow (i don't want to put too much code outside delegate as it will restrict us from generating workflows. Each time the workflow could have different number of tasks for each user). So the logic for locking needs to be generic for service tasks. All this is achieved using Receive Tasks and locking before signal and releasing in finally block and its works quite wel. How do we achieve same for the service tasks else we would be restricted to use Receive Tasks for all our requirements. Also attached the workflow we are using.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;public&amp;nbsp; class YourCompanyService {&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; private Set&amp;lt;String&amp;gt; processLocks = new HashSet&amp;lt;…&amp;gt;;&lt;BR /&gt;…&lt;BR /&gt;&lt;BR /&gt;public boolean printTheCard(String cardIdentifier) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // Correlate between card-id and task/process to use&lt;BR /&gt;&amp;nbsp;&amp;nbsp; String processId = runtimeService.createtaskQuery()……singleResult();&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // JVM-wide lock for this specific use-case.&lt;BR /&gt;&amp;nbsp;&amp;nbsp; boolean isSafe = false;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; synchronized(this) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; isSafe = processLocks.contains(processId);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(isSafe) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; processLocks.add(processId);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if(!isSafe) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throw new MyCompanyException("looks like you're too late…");&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; // important, release the lock in "finally"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; try {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Finish task&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; taskService……&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ….&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; finally&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; synchronized(this) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; processLocks.remove(processId);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;/CODE&gt;&lt;SPAN&gt;[/img]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 07:55:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/running-parallel-tasks-with-acitiviti/m-p/88898#M60366</guid>
      <dc:creator>hellowrakesh123</dc:creator>
      <dc:date>2012-07-04T07:55:19Z</dc:date>
    </item>
  </channel>
</rss>

