<?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: Process end time not available in process end listener in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89802#M61079</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Flushing changes before ending the command-context can be tricky and maybe break something else along the way, I don't recommend it. Can't you use the DelegateTask's variables itself in the end-listener (then they're not yet historic &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;Or, just a thought: Can't you add the logic in the layer on top of activity, that actually causes the process to complete?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 18 Jun 2012 09:59:36 GMT</pubDate>
    <dc:creator>frederikherema1</dc:creator>
    <dc:date>2012-06-18T09:59:36Z</dc:date>
    <item>
      <title>Process end time not available in process end listener</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89799#M61076</link>
      <description>Hi all,In my Activiti 5.9 project (with CDI, history = full), I've setup a global execution listener for the process end event via a custom BPMN parse listener. Inside the event handler, I try to load the current process instance via the HistoryService, but I see that historicProcessInstance.getEndT</description>
      <pubDate>Mon, 18 Jun 2012 09:10:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89799#M61076</guid>
      <dc:creator>naag</dc:creator>
      <dc:date>2012-06-18T09:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Process end time not available in process end listener</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89800#M61077</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Indeed, when the process-end listener is called the process flow itself is ended, but not yet marked as ended in the database. All changes in a single API-call (eg. completeTask() which causes the process to end) are flushed at the end of the call.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the HistoricProcessInstance manager is the way activiti handles entities internally. It's not part of the API and *could* be changed without backward-compatibility guarantees. However, this approach is stable and won't be changed any time soon. There have been talks/thoughts in the past to expose an API inside delegate/listener calls, but nothing concrete is planned, so this is the only way to get those values.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 09:19:38 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89800#M61077</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-18T09:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: Process end time not available in process end listener</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89801#M61078</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wow Frederik, you're really helpful here &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just noticed that the same problem happens with the HistoricVariableUpdates. I've looked for something comparable to the HistoricProcessInstanceManager and found the HistoricDetailManager, but it does not provide the queries that I require (I need to join ACT_HI_ACTINST). Of course I could loop over the result set, and execute multiple queries, but I'm afraid of bad performance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do you know of any safe way to flush the transient entities to the DB without affecting the rest of the system? E.g. call Context.getCommandContext().getDbSqlSession().flush() at the beginning of my end event handler? This way I could just use the HistoryService and custom JDBC queries to improve performance. I had some issues with that in the past, but maybe there's a trick to it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Peter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 09:50:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89801#M61078</guid>
      <dc:creator>naag</dc:creator>
      <dc:date>2012-06-18T09:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: Process end time not available in process end listener</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89802#M61079</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Flushing changes before ending the command-context can be tricky and maybe break something else along the way, I don't recommend it. Can't you use the DelegateTask's variables itself in the end-listener (then they're not yet historic &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;Or, just a thought: Can't you add the logic in the layer on top of activity, that actually causes the process to complete?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 09:59:36 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89802#M61079</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2012-06-18T09:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Process end time not available in process end listener</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89803#M61080</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh that's a brilliant idea, I mean just doing the logic AFTER the process is completed… I will try it out ASAP. Guess I looked at it for too long and got stuck with Activiti, never thinking out of the box &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt; I suppose with @Specializes and BusinessProcess bean, it should be a piece of cake &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again for the idea, I will post my solution once it's done!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Peter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Jun 2012 11:31:51 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89803#M61080</guid>
      <dc:creator>naag</dc:creator>
      <dc:date>2012-06-18T11:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Process end time not available in process end listener</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89804#M61081</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've now implemented it according to your idea and it works &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; What I did was to create a new class extending BusinessProcess (the CDI bean) and mark it with @Specializes so it's automatically hooked up. Then I override BusinessProcess.completeTask(), checking if the current process has ended, and if that's true I call to my logic.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just for someone who might get into the same situation: finding out if a process has ended is not intuitive, since processInstance.isEnded() doesn't work (always returns false, I believe there's a ticket somewhere for that…). Instead what you can do is query the RuntimeService with the processInstanceId and check if you get back a ProcessInstance. If so, it didn't end yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One more thought though: I think for such cases it would be appropriate to have a event fired by Activiti after the process has really ended, not just while it's ending. I guess I will open a new ticket for that as a possible improvement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Peter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Jun 2012 07:37:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/process-end-time-not-available-in-process-end-listener/m-p/89804#M61081</guid>
      <dc:creator>naag</dc:creator>
      <dc:date>2012-06-19T07:37:22Z</dc:date>
    </item>
  </channel>
</rss>

