<?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: Inconsistent procvar behaviour in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70432#M45440</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The forum doesn't seem to allow attaching files:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color:#FF0000;"&gt;The extension diff is not allowed.&lt;/SPAN&gt;&lt;SPAN&gt; (Same happens with other extensions)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I made a Jira issue:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://jira.codehaus.org/browse/ACT-934" rel="nofollow noopener noreferrer"&gt;http://jira.codehaus.org/browse/ACT-934&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 20 Sep 2011 08:37:52 GMT</pubDate>
    <dc:creator>marcus1</dc:creator>
    <dc:date>2011-09-20T08:37:52Z</dc:date>
    <item>
      <title>Inconsistent procvar behaviour</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70430#M45438</link>
      <description>I found some strange behaviour regarding the storing and updating of process variables. Suppose we have the following process&lt;IMG id="smileytongue" class="emoticon emoticon-smileytongue" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-tongue.png" alt="Smiley Tongue" title="Smiley Tongue" /&gt;rocess A&lt;IMG id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;ervice 1 -&amp;gt; Task 1 -&amp;gt; Service 2 -&amp;gt; Task 2 -&amp;gt; Service 3Service 1 creates a new process variable:Book book = new Book("12345");execution.setVariable("boo</description>
      <pubDate>Mon, 19 Sep 2011 15:17:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70430#M45438</guid>
      <dc:creator>marcus1</dc:creator>
      <dc:date>2011-09-19T15:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent procvar behaviour</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70431#M45439</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;Can you attach a working test project for this problem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Sep 2011 18:48:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70431#M45439</guid>
      <dc:creator>trademak</dc:creator>
      <dc:date>2011-09-19T18:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent procvar behaviour</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70432#M45440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The forum doesn't seem to allow attaching files:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="color:#FF0000;"&gt;The extension diff is not allowed.&lt;/SPAN&gt;&lt;SPAN&gt; (Same happens with other extensions)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I made a Jira issue:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://jira.codehaus.org/browse/ACT-934" rel="nofollow noopener noreferrer"&gt;http://jira.codehaus.org/browse/ACT-934&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Sep 2011 08:37:52 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70432#M45440</guid>
      <dc:creator>marcus1</dc:creator>
      <dc:date>2011-09-20T08:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent procvar behaviour</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70433#M45441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think your problem is similar to this one : &lt;/SPAN&gt;&lt;A href="http://jira.codehaus.org/browse/ACT-820" rel="nofollow noopener noreferrer"&gt;http://jira.codehaus.org/browse/ACT-820&lt;/A&gt;&lt;SPAN&gt;, discussed here : &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=1720" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=1720&lt;/A&gt;&lt;SPAN&gt; and here &lt;/SPAN&gt;&lt;A href="http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=2394" rel="nofollow noopener noreferrer"&gt;http://forums.activiti.org/en/viewtopic.php?f=6&amp;amp;t=2394&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You need to re-affect the variable each time you update it :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;Book book = execution.getVariable("book");&lt;BR /&gt;book.setTitle("Activiti in Action");&lt;BR /&gt;execution.setVariable("book", book);&lt;BR /&gt;&lt;/CODE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 08:02:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70433#M45441</guid>
      <dc:creator>mathiasd</dc:creator>
      <dc:date>2011-09-21T08:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent procvar behaviour</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70434#M45442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;@Mathias: Good catch, I missed that…&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Sep 2011 12:57:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70434#M45442</guid>
      <dc:creator>ronald_van_kuij</dc:creator>
      <dc:date>2011-09-21T12:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent procvar behaviour</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70435#M45443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;@Mathias: good to know that other people have encountered this issue. I hope we can find a solution to this &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems to me that the cause of the problem is as follows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Lets first look at what happens in case of &lt;/SPAN&gt;&lt;STRONG&gt;Process A&lt;/STRONG&gt;&lt;SPAN&gt;, which (AFAIK) works as intended.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When setVariable is called from Service1, first the list of variableInstances is initialized. Then a new VariableInstanceEntity is created. The call hierarchy is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecutionEntity(VariableScopeImpl).setVariable&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;—-ExecutionEntity(VariableScopeImpl).createVariableLocal&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;——–VariableInstanceEntity.createAndInsert&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;————VariableInstanceEntity.create&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;—————-VariableInstanceEntity.setValue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;——————–SerializableType.setValue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;————————ValueFields.setCachedValue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;—————————-cachedValue = …&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;————————cachedValue = … &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the variable is created and added to the SqlSession, and the cachedValue is set (twice actually).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The next step in the process is a task, so the db session is flushed, causing the ExecutionEntity (and the variable) to be written to the database.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After that the next step is Service2, which calls getVariable. The call hierarchy looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecutionEntity(VariableScopeImpl).getVariable&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;—-ExecutionEntity(VariableScopeImpl).ensureVariableInstancesInitialized &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;(not initialized yet, so fetch from db)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;—-VariableInstanceEntity.getValue &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;(cachedValue is null)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;——–SerializableType.getValue &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;(only called if cachedValue is null)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;————DbSqlSession.addDeserializedObject&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So ultimately getVariable causes DbSqlSession.addDeserializedObject to be called. As I understand it, this ensures that variables with updated values are flushed at the end of the transaction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What about &lt;/SPAN&gt;&lt;STRONG&gt;Process B&lt;/STRONG&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The difference with Process A is the task between Service1 and Service2, so we need only look at what happens in Service2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When Service2 calls setVariable, this is what happens:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ExecutionEntity(VariableScopeImpl).getVariable&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;—-ExecutionEntity(VariableScopeImpl).ensureVariableInstancesInitialized &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;(already initialized!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;—-VariableInstanceEntity.getValue &lt;/SPAN&gt;&lt;SPAN style="color:#FF0000;"&gt;(cachedValue is already set!)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;——–return cachedValue&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In this case, cachedValue is not null, so SerializableType.setValue and thus &lt;/SPAN&gt;&lt;STRONG&gt;DbSqlSession.addDeserializedObject&lt;/STRONG&gt;&lt;SPAN&gt; is never called!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Solution&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In my view, the conceptual solution is simple: addDeserializedObject needs to be called when a new variable is created, not just from getVariable.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Sep 2011 08:38:30 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70435#M45443</guid>
      <dc:creator>marcus1</dc:creator>
      <dc:date>2011-09-24T08:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Inconsistent procvar behaviour</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70436#M45444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Added a patch to &lt;/SPAN&gt;&lt;A href="http://jira.codehaus.org/browse/ACT-934" rel="nofollow noopener noreferrer"&gt;http://jira.codehaus.org/browse/ACT-934&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Sep 2011 09:35:46 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/inconsistent-procvar-behaviour/m-p/70436#M45444</guid>
      <dc:creator>marcus1</dc:creator>
      <dc:date>2011-09-24T09:35:46Z</dc:date>
    </item>
  </channel>
</rss>

