<?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 Trying to understand how service tasks and listeners work  in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/trying-to-understand-how-service-tasks-and-listeners-work/m-p/204774#M157904</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We are having a problem and we'd like to understand a bit how Activiti's Engine works. Let assume the following flow example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;start -&amp;gt; ServiceTask1 -&amp;gt; ServiceTask2 -&amp;gt; end&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;Both ServiceTasks are async&lt;/LI&gt;&lt;LI&gt;Both ServiceTasks has a Listener when each of them starts.&lt;/LI&gt;&lt;LI&gt;Both Listeners update a row in one of our business tables.&lt;/LI&gt;&lt;/UL&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that we are having Optimistic Lock errors because it seems that both listeners are trying to update the same row at the same time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We guess that what is happening is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;The ServiceTask doesn't wait for the start Listener to finish&lt;/LI&gt;&lt;LI&gt;So ServiceTask1 finishes before its start Listener finishes and the start Listener of ServiceTask2 reads the db row before the Listener of ServiceTask1 writes the update&lt;/LI&gt;&lt;LI&gt;ServiceTask1's Listener writes the update&lt;/LI&gt;&lt;LI&gt;When ServiceTask2's Listener wants to write the update, the version is different so it throws an optimistic lock.&lt;/LI&gt;&lt;/UL&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, the questions we need to answer are:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;Is this how ServiceTask's Listeners works or are we missing something?&lt;/LI&gt;&lt;LI&gt;Is there any way to make ServiceTasks to wait for the start Listener?&lt;/LI&gt;&lt;/UL&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Apr 2015 14:12:49 GMT</pubDate>
    <dc:creator>neuquino</dc:creator>
    <dc:date>2015-04-16T14:12:49Z</dc:date>
    <item>
      <title>Trying to understand how service tasks and listeners work</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/trying-to-understand-how-service-tasks-and-listeners-work/m-p/204774#M157904</link>
      <description>We are having a problem and we'd like to understand a bit how Activiti's Engine works. Let assume the following flow example:start -&amp;gt; ServiceTask1 -&amp;gt; ServiceTask2 -&amp;gt; endBoth ServiceTasks are asyncBoth ServiceTasks has a Listener when each of them starts.Both Listeners update a row in one of</description>
      <pubDate>Thu, 16 Apr 2015 14:12:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/trying-to-understand-how-service-tasks-and-listeners-work/m-p/204774#M157904</guid>
      <dc:creator>neuquino</dc:creator>
      <dc:date>2015-04-16T14:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to understand how service tasks and listeners work</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/trying-to-understand-how-service-tasks-and-listeners-work/m-p/204775#M157905</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;BLOCKQUOTE class="jive-quote"&gt;Is this how ServiceTask's Listeners works or are we missing something?&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;No, It should not work in this way. ServiceTask1 transaction is committed after the ServiceTask2&amp;nbsp; job is created. But I do not know what you missed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(can you create jUnit test? &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/content/sticky-how-write-unit-test" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/content/sticky-how-write-unit-test&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Martin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Apr 2015 06:47:03 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/trying-to-understand-how-service-tasks-and-listeners-work/m-p/204775#M157905</guid>
      <dc:creator>martin_grofcik</dc:creator>
      <dc:date>2015-04-17T06:47:03Z</dc:date>
    </item>
  </channel>
</rss>

