<?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 How can I prevent a process execution is run multiple times? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97460#M67075</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;BR /&gt;&lt;SPAN&gt;we provide a list of open tasks to our users.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The same user can display this list in different web sessions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;He or she may proceed the same task from different sessions at nearly the same time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This results in multiple calls to taskService.complete(taskId) with the same taskId.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I expect that the second and all further calls of taskService.complete(taskd) fail, but they do not - at least if the first call is still be executed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I prevent multiple executions of the same task?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Markus Mueller&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Jun 2012 16:39:12 GMT</pubDate>
    <dc:creator>mamue</dc:creator>
    <dc:date>2012-06-19T16:39:12Z</dc:date>
    <item>
      <title>How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97460#M67075</link>
      <description>Hi, we provide a list of open tasks to our users.The same user can display this list in different web sessions.He or she may proceed the same task from different sessions at nearly the same time.This results in multiple calls to taskService.complete(taskId) with the same taskId.I expect that the sec</description>
      <pubDate>Tue, 19 Jun 2012 16:39:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97460#M67075</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-19T16:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97461#M67076</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;An org.activiti.engine.ActivitiOptimisticLockingException is thorn when the threads actually call the same method simultaneously. Otherwise (if first transaction is committed before second one does the call), an ActivitiException will be thrown (task not found).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The logic using the engine should be prepared for this, and potentially retry or check if operation that is performed is still valid (eg. check task exists).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 07:16:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97461#M67076</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-20T07:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97462#M67077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Frederik,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you very much for your reply.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've now built a small test demo:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A process consisting of a user task followed by a service task which contains a delay of one second.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I run this test slowly in debugger, there is the exception "task not found" - exactly as you have predicted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But if I run the test without any breakpoints set, then there is &lt;/SPAN&gt;&lt;EM&gt;no&lt;/EM&gt;&lt;SPAN&gt; exception - both calls of taskService.complete() succeed: The single service task is executed twice and in parallel!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You find the source code in attached zip file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can copy the files directly in the Activiti 5.9 demo workspace "activiti-engine-examples".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MaMü&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jun 2012 16:47:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97462#M67077</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-20T16:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97463#M67078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Doesn't seem to fail here when running… Are you sure you get no failture when just running it?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 08:24:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97463#M67078</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-21T08:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97464#M67079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Frederik,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;please check the console log for stack dumps to find the cause of the test failure - or set a breakpoint on ae.printStackTrace(); in method CompleterThread.run().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have run the test on my box just now in debugger (without any breaks set) and outside debugger (ie. with run command of eclipse):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Always I see the green bar of junit and no stack dumps in console view.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MaMue&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 08:50:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97464#M67079</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-21T08:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97465#M67080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Frederik,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;currently the test is green if activiti behaves not as expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This is a little bit twisted. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore I have changed the second check of the succeeded flag:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //assertTrue("Second complete() failed.", thread2.isSucceeded());&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assertFalse("Second complete() didn't fail as expected. ", thread2.isSucceeded());&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;Now the test fails as long as activiti does not guarantee that a task may be completed only once.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this would be more clear to a casual reader of the test.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MaMü&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 09:14:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97465#M67080</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-21T09:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97466#M67081</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;BR /&gt;&lt;SPAN&gt;Discovered what is going on. The optimistic-locking mechanism that is in place, is not triggered in the process you attached. After completing the task, the execution is not persisted anymore, hence the "revision" of the execution isn't altered. This causes the 2 task.completes() to actually be successful simultaneously. When adding an additional user-task (or other wait-state like receive-taks) after the userTaks in your process, the second thread actually fails:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;org.activiti.engine.ActivitiOptimisticLockingException: ExecutionEntity[5] was updated by another transaction concurrently&lt;BR /&gt; at org.activiti.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:476)&lt;BR /&gt; at org.activiti.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:372)&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;Good catch, I'll make sure this gets implemented in 5.10 release, you can track this here: &lt;/SPAN&gt;&lt;A href="https://jira.codehaus.org/browse/ACT-1259" rel="nofollow noopener noreferrer"&gt;https://jira.codehaus.org/browse/ACT-1259&lt;/A&gt;&lt;SPAN&gt;. So this only occurs if the last task of a process is completed concurrently. As current workaround, you should add some kind of synchronized mutex/lock based on process/task-id in the logic that actually calls the Activiti API to be absolutely sure. This wouldn't cause a big overhead I guess unless you have high concurrency&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Jun 2012 19:34:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97466#M67081</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-21T19:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97467#M67082</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Frederik,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thank you very much for analyzing the problem and creating issue ACT-1259.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW, I think I have found the problem shown in &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/en/download/file.php?id=634" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/en/download/file.php?id=634&lt;/A&gt;&lt;SPAN&gt; above:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The second thread may start accidentally before the first thread.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To avoid this race condition I have added a small sleep between the starting of thread1 and thread2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is still another problem - but an unresolved one:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The service task in my example represents (or is accompanied by) a physical production process of a new ID card.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a) This production process may last a few tens of seconds.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;b) The production process is not "transactional", i.e. if the ID card is produced, it exists and can't be "rolled back".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Both aspects are the cause of problems:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;a) The user who comes in second has to wait the few tens seconds before he gets the failure. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;b) The additional ID card (that can't be used because it is a duplicate and because the corresponding database record can't be saved successfully) causes waste and charges.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The bottom line is: We need a chance to check the situation quickly and &lt;/SPAN&gt;&lt;EM&gt;before&lt;/EM&gt;&lt;SPAN&gt; executing the pending service task and this check must be done transactionally.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a chance that Activiti will provide this feature?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attached you find a jUnit test which demonstrates the problem. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The TaskFailureDelay test consists of a user task, followed by the service task which needs ten seconds, followed by the second user task.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The test fails because the second complete call needs too much time before it fails.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MaMü&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 14:22:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97467#M67082</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-22T14:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97468#M67083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As I suggested, add some kind of mutex-mechanism in the layer above the Activiti-layer. Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&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;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;This is just off the top of my head, doesn't actually compile &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; To make it more "generic" (if you have more of these CRITICAL stuff that needs exception right away before actually performing the operation and getting optimisticLockEx) you can build some kind of callback mechanism (like springs doInTransactions, but then doWhilLockingProcess(processId).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 14:45:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97468#M67083</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-22T14:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97469#M67084</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Frederik,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; … add some kind of mutex-mechanism …&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ok, we can implement this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It must be a database based mutex, not a Java based mutex, because there may be several parallel machines/JVMs (because of load balancing etc).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; … you can build some kind of callback mechanism … spring …&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cool idea, yes this would be nice!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This database based mutex is needed always if there are time-consuming tasks or tasks with non-transactional workload.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I think this is a general requirement which may be needed by many Activiti users, isn't it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a chance that Activiti will provide this feature some day?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In Activiti this feature may be perhaps simply achieved by an additional flush before the delegate is called, isn't it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MaMü&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 15:34:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97469#M67084</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-22T15:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97470#M67085</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If a flush is needed before the delegate is called, maybe using activiti:async="true" can help. This way, at least, one of the 2 competing consumer-threads will get the OptimisticLockException (also in current codebase without issue resolved) and fail before the time-consuming operation starts. Also, any NEW threads completing the task, will get a "task not found"…&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Jun 2012 18:21:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97470#M67085</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-22T18:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97471#M67086</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Frederik wrote: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; … maybe using activiti:async="true" can help …&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok, this solves the problem that the failure is time-consuming.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If two users want to complete the same task at the same time, one of them will succeed, the other will fail &lt;/SPAN&gt;&lt;EM&gt;immediately&lt;/EM&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But now there is another problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The following asynchronous tasks are executed by the Activiti Job Executor using another thread from a thread pool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This thread knows &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- neither our SessionContext containing the ID of the currently processed tenant &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- nor the UI session data of our GUI framework&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- nor any data based on Thread Local Storage.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Concerning our concrete use case (production of an ID card on client side) the attribute activiti:async="true" does not help, sorry.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MaMü&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Jun 2012 17:03:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97471#M67086</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-25T17:03:51Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97472#M67087</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All variables relevant to the process can be stored as process variables. All other stuff that needs to be referenced (this being services, temporal stuff, …) can be done using your own lookup mechanism or alternatively, following JPAVariableType's example, you can create process-variables types that do eg. a lookup in your context for a certain value instead of just storing a string or an int.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But it seems that your process doesn't have an async nature, you do the call and expect, when the thread returns, the process has finished. Then the only option is to create the mutex mechanism to prevent 2 tasks from starting. But if this is a DB-mutex, again this can create the same issues (unless a full-table lock is done)…&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 07:22:16 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97472#M67087</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-26T07:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97473#M67088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Frederik,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you wrote:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; But it seems that your process doesn't have an async nature …&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok, I think so too.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; … the only option is to create the mutex mechanism to prevent 2 tasks from starting. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; But if this is a DB-mutex, again this can create the same issues (unless a full-table lock is done)…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Look at the following figure:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[attachment=0]lock.png[/attachment]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Locking the task completion has to take place in an own, isolated database transaction before taskService.complete() is called.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As soon as taskService.complete() returns (or throws an exception) the task must be unlocked. This has to take place also in an own isolated transaction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We want to &lt;/SPAN&gt;&lt;EM&gt;lock&lt;/EM&gt;&lt;SPAN&gt; because the service task may contain non-transactional operations (sending emails, producing cards, …) which can't be rolled back and which must be prevented to be executed several times.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Locking must be done via &lt;/SPAN&gt;&lt;EM&gt;database&lt;/EM&gt;&lt;SPAN&gt; (instead of java.util.HashMap) because there might be several JVMs involved in case of load balancing etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The locking transactions must be &lt;/SPAN&gt;&lt;EM&gt;own and isolated&lt;/EM&gt;&lt;SPAN&gt; because we want to fail fast (i.e. &lt;/SPAN&gt;&lt;EM&gt;before&lt;/EM&gt;&lt;SPAN&gt; the first complete call is executed completely).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Locking/unlocking can be achieved by inserting/deleting a new record in an additional database table with the taskId as key.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This way only one of the simultaneously working users succeeds in completing the task, all other calling users will fail immediately.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume that this approach will reliably work also across process boundaries and hosts - provided that the system does not crash.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If a machine crashs and the unlocking is skipped there will remain a locked taskId in the additional database table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Years ago, in our previous product we implemented a database based mutex with an additional thread which did a "heartbeat" on every active locking record:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Every few seconds the locking record was updated with a current timestamp and an individual ID by the thread which held the lock.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;A competing locking thread in another JVM was allowed to replace the record by it's own ID and current timestamp if and only if it detected a foreign old timestamp (e.g. older than one minute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In this situation the first thread probably has died unexpectedly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Some more years ago we used a simpler database based locking mechanism which needed user interaction after system has crashed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably the simple solution which needs user interaction after system crash is not state of the art.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So we must implement the heartbeat based mutex in our current product.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On the other hand the requirement to lock taskIds is not specific to our product.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume that most users of Activiti will place some non-transactional operations in their processes following user tasks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore it would be a good idea to implement this feature inside Activiti, isn't it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Markus Müller&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 13:54:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97473#M67088</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-26T13:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97474#M67089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I see it more as a "special type of activity" or perhaps execution-listener that can be plugged on a service-task (listeners at start, end) that do this locking and unlocking rather than something inside the engine itself, but I can be mistaken. In my opinion this is outside the scope of the engine itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nevertheless, it's a valid additional feature for activiti and could be more like a mechanism "on top".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 14:03:29 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97474#M67089</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-26T14:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97475#M67090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Frederik,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm afraid of that if we use execution listeners then locking will take place too often as shown in the following figure:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[attachment=0]lock2.png[/attachment]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Actually we need only the blue lock/unlock, not the multiple green locks/unlocks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What happens if a competing call to taskService.complete() comes just after the unlock of task A but before the lock of task B?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Where does the taskId in the start and end listeners come from?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another question is what happens if exceptions are thrown. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Are end listeners called in case of exceptions which are thrown while the service tasks are executed?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What about an additional attribute &lt;/SPAN&gt;&lt;EM&gt;activiti:threadsafe=none/local/global&lt;/EM&gt;&lt;SPAN&gt; which can be added to a &lt;/SPAN&gt;&lt;EM&gt;&amp;lt;process&amp;gt;&lt;/EM&gt;&lt;SPAN&gt; element?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- &lt;/SPAN&gt;&lt;EM&gt;none&lt;/EM&gt;&lt;SPAN&gt;:&amp;nbsp;&amp;nbsp; no locking&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- &lt;/SPAN&gt;&lt;EM&gt;local&lt;/EM&gt;&lt;SPAN&gt;:&amp;nbsp; locking using java.util.Map or something similar&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- &lt;/SPAN&gt;&lt;EM&gt;global&lt;/EM&gt;&lt;SPAN&gt;: database based locking&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"none" may be used by single user applications.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"local" may be used by web applications, multiuser- and multithreaded-applications if there is at most a single JVM active.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"global" must be used if the application runs on several machines in parallel.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This way the time consuming database based locking can be avoided if it is not needed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Markus Müller&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Jun 2012 16:46:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97475#M67090</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-26T16:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97476#M67091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good point about the exceptions… listeners aren't notified about this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not the only one to decide about this feature but it seems that this is very useful when dealing with non-transactional resources. Indeed, process-level declaration and defaulting to "none" would be the best approach.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems you have a clear idea on what needs to be implemented and know a thing or two about the Activiti internals. It would certainly help if you could contribute a patch, if you decide to implement it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 06:47:25 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97476#M67091</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-27T06:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97477#M67092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm a bit confused here as it seems several problems are being described, but with regards to the task.complete() locking i tend to agree that this should be handled outside of the engine in your application layer. Whatever Activiti would implement to handle this i doubt it would suffice for all possible cases and the added complexity might just not be worth it there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;From what i understand about the problem, would it not be easier to just wrap your task.complete() with a hazelcast-lock on the task id ? &lt;/SPAN&gt;&lt;A href="http://www.hazelcast.com/documentation.jsp#Lock" rel="nofollow noopener noreferrer"&gt;http://www.hazelcast.com/documentation.jsp#Lock&lt;/A&gt;&lt;SPAN&gt; ?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 07:47:21 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97477#M67092</guid>
      <dc:creator>heymjo</dc:creator>
      <dc:date>2012-06-27T07:47:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97478#M67093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hazelcast.com - very cool library I didn't know until now. Good hint, thank you very much, Jorg.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We could use this library to encapsulate the &lt;/SPAN&gt;&lt;EM&gt;taskService.complete&lt;/EM&gt;&lt;SPAN&gt; call:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Lock lock = Hazelcast.getLock("taskId" + taskId);&lt;BR /&gt;lock.lock();&lt;BR /&gt;try {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; taskService.complete(taskId);&lt;BR /&gt;} finally {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lock.unlock();&lt;BR /&gt;} &lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;As far as I know Hazelcast uses by default IP multicast to find other servers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There additional problems arise:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- What if there are other servers in LAN which are working on other databases or even other applications?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- What if there are firewalls active?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- What if there is no IP at all?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is possible to configure concrete TCP/IP details of all cooperating servers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But this will be extra work and perhaps tricky for an administrator which does not know the internals.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We already have a common base - the database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Our application and also Activiti does not run without a common database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is obvious to an administrator that she must configure firewalls etc. so that each server can reach the single database via the JDBC URL etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A transparent way to do the locking is therefore to use this single database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The only drawback is that we do not know the concrete type of RDBMS so the used locking mechanism must be a very basic one (e.g. select+insert+commit and delete+commit)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This way the whole TCP/IP configuration stuff may be avoided.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The remaining configuration options probably will be the time span after which a server is considered dead after its last heartbeat, and the time span between the heartbeats.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I expect that our old default values will also work very well in this situation: The heart of an active lock beats every six seconds and 60 seconds after the last heartbeat a server may be considered as dead by competing servers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;With the additional &lt;/SPAN&gt;&lt;EM&gt;&amp;lt;process&amp;gt;&lt;/EM&gt;&lt;SPAN&gt; attribute &lt;/SPAN&gt;&lt;EM&gt;activiti:threadsafe=none/local/global&lt;/EM&gt;&lt;SPAN&gt; the overhead of the heartbeats is restricted to distributed deployments. And at all, as long as there are no mutex active there are also no heartbeats.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The following screenshot shows how it may look in the database:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[attachment=0]mutex.png[/attachment]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The table ACT_RU_MUTEX may be used by Activiti for &lt;/SPAN&gt;&lt;EM&gt;any&lt;/EM&gt;&lt;SPAN&gt; mutex requirements.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Here the NAME_ is composed of an "class name" and the taskId itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The TIME_STAMP_ holds the time of the last heartbeat. The first record seems to belong to a died server and may be evicted.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The GUID_ is a random value which is used by the servers to distinguish own records from foreign records. Each server generates the GUID_ itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The BEAT_ stores the configured seconds between the heartbeat.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The LATENCY_ stores the configured time after which a heartbeat may be considered as the last of a died server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Mutex implementation may be done apart from any concrete use case so it may be used throughout the whole project.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kind regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Markus Müller&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jun 2012 16:21:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97478#M67093</guid>
      <dc:creator>mamue</dc:creator>
      <dc:date>2012-06-27T16:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I prevent a process execution is run multiple times?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97479#M67094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;A transparent way to do the locking is therefore to use this single database.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;I understand your reasoning but i don't agree with it. For me simplicity goes a very long way, and the 5 lines of java to obtain a solid global lock - even across different applications on different clusters - outweigh any database based mechanism which will always be local to one&amp;nbsp; application. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I guess it also depends on the technology that is trusted the most in your organisation, that's definitely a factor as well. Which is exactly why activiti should not embed this in the core.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2012 05:42:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-can-i-prevent-a-process-execution-is-run-multiple-times/m-p/97479#M67094</guid>
      <dc:creator>heymjo</dc:creator>
      <dc:date>2012-06-28T05:42:11Z</dc:date>
    </item>
  </channel>
</rss>

