<?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: Querying to find currently waiting receive tasks in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95589#M65596</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you do something like getting a list of tasks for the processInstanceId you have, then looping through and checking their status:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery();&lt;BR /&gt;&lt;BR /&gt;List&amp;lt;Task&amp;gt; tasks = taskQuery.processInstanceId(processInstanceId).list();&lt;BR /&gt;&lt;BR /&gt;for (Task task : tasks) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (task.getDelegationState == DelegationState.PENDING) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do stuff&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Apr 2012 22:36:02 GMT</pubDate>
    <dc:creator>ryanp</dc:creator>
    <dc:date>2012-04-04T22:36:02Z</dc:date>
    <item>
      <title>Querying to find currently waiting receive tasks</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95588#M65595</link>
      <description>Hi guys,I've taken this example from the activiti site:&amp;lt;receiveTask id="waitState" name="wait" /&amp;gt;&amp;nbsp; ‍&amp;nbsp; To continue a process instance that is currently waiting at such a receive task, the runtimeService.signal(executionId) must be called using the id of the execution that arrived in the receive</description>
      <pubDate>Wed, 04 Apr 2012 18:01:23 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95588#M65595</guid>
      <dc:creator>imamchishty</dc:creator>
      <dc:date>2012-04-04T18:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Querying to find currently waiting receive tasks</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95589#M65596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you do something like getting a list of tasks for the processInstanceId you have, then looping through and checking their status:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery();&lt;BR /&gt;&lt;BR /&gt;List&amp;lt;Task&amp;gt; tasks = taskQuery.processInstanceId(processInstanceId).list();&lt;BR /&gt;&lt;BR /&gt;for (Task task : tasks) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp; if (task.getDelegationState == DelegationState.PENDING) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // do stuff&lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Apr 2012 22:36:02 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95589#M65596</guid>
      <dc:creator>ryanp</dc:creator>
      <dc:date>2012-04-04T22:36:02Z</dc:date>
    </item>
    <item>
      <title>Re: Querying to find currently waiting receive tasks</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95590#M65597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I know this was posted a long time ago, but I have actually the same problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In my case, we use messages to signal processes waiting in receive tasks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So we do something like this: (in our case we use CDI injection)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;CODE&gt;&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; // retrieve the current execution context of the process Id in the waiting state&lt;BR /&gt;&amp;nbsp; Execution execution = runtimeService.createExecutionQuery()&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .processInstanceId(businessProcess.getProcessInstanceId())&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .messageEventSubscriptionName("continueMessage")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .singleResult();&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;In this way, we don't need to know the Activity id,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;but we still need to know the name of the message the process is waiting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any way to even avoid that? ( using Activiti 5.19.0.2 )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot in advance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2016 08:50:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95590#M65597</guid>
      <dc:creator>maikelnait</dc:creator>
      <dc:date>2016-04-26T08:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Querying to find currently waiting receive tasks</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95591#M65598</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, that's not possible. What would be the alternative if you don't want to use the message name?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2016 11:03:40 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95591#M65598</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2016-04-26T11:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Querying to find currently waiting receive tasks</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95592#M65599</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In our application we want to work in the following way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) A user clicks on a button in the UI, starting a BPM Activiti process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) When the flow reaches a receive task, (we need input from the user) the UI is updated with a new screen.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (we don't use user tasks, because we don't use the User concept from Activiti)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) When the user fills whatever information is needed, he clicks on a button to "continue" the flow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steps 2) and 3) may be repeated several times, depending on how many screens the user needs to traverse to complete the flow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Somehow we are mixing the concepts of page-flow with business-flow, as explained in the article:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://www.bpm-guide.de/2012/04/04/pageflow-vs-process-flow-and-ui-mediator-pattern" rel="nofollow noopener noreferrer"&gt;http://www.bpm-guide.de/2012/04/04/pageflow-vs-process-flow-and-ui-mediator-pattern&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now the point is, each time the user clicks on a button to "continue" the flow, we cannot just use a "global common" function to ask the current process to just continue, because we need to know either the activity id, or the message id, to get the correct Execution Id, so we can proceed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the end, every time a user clicks on a button, we know that the current process for that user is in a "waiting state", persisted in a DB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And from our understanding, a particular process instance Id can only be in a single waiting state at a particular time, so there should be an API like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"runtimeService.createExecutionQuery().processInstanceId(businessProcess.getProcessInstanceId()).&lt;/SPAN&gt;&lt;STRONG&gt;inWaitingState()&lt;/STRONG&gt;&lt;SPAN&gt;.singleResult()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably this could not work with parallel executions, but in our case we don't use them, so that API would give us the correct Execution Id, without the need to know any particular activity id or message name.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another thing is that, after getting the Execution Id, we still need to know the message name to resume the process execution waiting in the receive task.&amp;nbsp; We use messages, because the user can choose basically "continue" or "cancel" options in each step, so we use two different message names to decide which should be the next step in the flow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To avoid even having to know this, we are also thinking of using a simple "signal" event, -without the need to know the signal name-, and include some execution variables, so depending on the user's choice, the flow would go on different paths based on a gateway.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;At the end, we want to simplify the Java part that deals with how to call / continue activiti processes from the presentation layer ( we use JSF for the page-flow design ), and concentrate most of the work in the BPM design itself, so different customers will not need to modify existing java code for the page-flows, (as much as possible), and only work on the "business side" flows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, not sure if this is possible, because we are just new to Activiti and BPM in general.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Apr 2016 08:03:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95592#M65599</guid>
      <dc:creator>maikelnait</dc:creator>
      <dc:date>2016-04-27T08:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Querying to find currently waiting receive tasks</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95593#M65600</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think I have found a way to achieve what I want, with the following Native Execution Query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;CODE&gt;&lt;BR /&gt;runtimeService.createNativeExecutionQuery()&lt;BR /&gt;.sql("SELECT * FROM " + mgmtService.getTableName(Execution.class) + " WHERE PROC_INST_ID_ = #{processInstanceId} AND IS_ACTIVE_ = 1" ).parameter("processInstanceId", processInstance.getProcessInstanceId()).singleResult();&lt;BR /&gt;&lt;/CODE&gt;&lt;BR /&gt;&lt;SPAN&gt;The key point is that, in our application we only use SEQUENTIAL processes, not parallel ones, so by knowing the process instance Id, we just need to query the Execution table with the [IS_ACTIVE_ = 1] filter, which always gives us the latest "persisted" Execution of the process, which is our "waiting state", just the one we need to signal to continue.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As long as we don't use parallel flows, does this approach present any caveats or potential problems ?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot !&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Apr 2016 09:26:48 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95593#M65600</guid>
      <dc:creator>maikelnait</dc:creator>
      <dc:date>2016-04-28T09:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Querying to find currently waiting receive tasks</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95594#M65601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;"And from our understanding, a particular process instance Id can only be in a single waiting state at a particular time, so there should be an API like:"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As you said, this does not apply to parallel execution, nor subprocesses and certain other constructs and definitely not for the v6!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems you are indeed mixing a few bits. Also, the typical way to do what you want, is to use data (variables) and use exclusive gateways AFTER the receive task/user task, to correlate with buttons from the user.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"The key point is that, in our application we only use SEQUENTIAL processes,"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are sequential processes that also have more than one execution.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 12:05:47 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95594#M65601</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2016-05-03T12:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Querying to find currently waiting receive tasks</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95595#M65602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks a lot for the tips!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Currently we are also exploring the usage of User Tasks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One problem we found while using the previous approach, is that it's hard to chain flows with the "Call Activity" functionality, because different flows will run with different process id's, so after pressing a button, the process id that we stored beforehand may not be the correct one for signaling, if the next receive task belongs to a "called activity" step. Indeed there are many tricky situations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, with User Tasks, we don't need to know the process id, even if we chain flows. All we need is to query the pending user tasks with the correct assignee, and ensure we get the one that corresponds to the current page. In this sense, what we need is more related to the original answer… we are going to do some further tests with User Tasks, and see if we can come with an "easy" API for customers to use without too much knowledge of the Activiti internals.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot so far !&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 May 2016 01:17:54 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/querying-to-find-currently-waiting-receive-tasks/m-p/95595#M65602</guid>
      <dc:creator>maikelnait</dc:creator>
      <dc:date>2016-05-04T01:17:54Z</dc:date>
    </item>
  </channel>
</rss>

