<?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: Start a workflow if it has not been started? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2733#M711</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An interesting problem and actually one that matches a project we completed recently for one of our clients.&lt;BR /&gt;Ignoring the message receiver classes for which I imagine you will create a message driven bean, rest endpoint or other custom handler to call into the workflow engine.&lt;BR /&gt;Your description indicates that it is possible for other messages to arrive while the process is being started or while a given event is processed and it is therefore possible to lose these messages.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As such, you need to use a publish and subscribe pattern rather to simply throwing the events at the process engine and hoping they get caught.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the first message for a given groupID start the process AND put the message into a list (you can use an in memory store or DB table, really depends on the scenario).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, when the process starts have it go out and look for messages (obviously there will be at least one) and retrieve them, basically a polling pattern, when all types are received, clear the group from the list and move on with the process.&lt;/P&gt;&lt;P&gt;This way we process as many messages as are available at any given moment and can't miss any since we are decoupled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this makes sense,&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;P&gt;&lt;A href="https://migration33.stage.lithium.com/t5/tag/bp3/tg-p"&gt;&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jan 2017 19:52:37 GMT</pubDate>
    <dc:creator>gdharley</dc:creator>
    <dc:date>2017-01-11T19:52:37Z</dc:date>
    <item>
      <title>Start a workflow if it has not been started?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2731#M709</link>
      <description>My application expects a related group of events. I would like to construct a workflow that waits for all the events from the group to arrive (or times out), and then proceeds. &amp;nbsp;Each group and each event have a UID associated with it. &amp;nbsp;The events&amp;nbsp;arrive at random times, and are unknown to my applica</description>
      <pubDate>Mon, 09 Jan 2017 20:32:04 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2731#M709</guid>
      <dc:creator>blezek</dc:creator>
      <dc:date>2017-01-09T20:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Start a workflow if it has not been started?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2732#M710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Looks like you are looking for the ability to start a process by an event message. Activiti provides 'Message Start Event' that allows you to start a process instance by a message. Have a look at the doc here&amp;nbsp;&lt;A class="link-titled" href="https://www.activiti.org/userguide/#bpmnMessageStartEvent" title="https://www.activiti.org/userguide/#bpmnMessageStartEvent" rel="nofollow noopener noreferrer"&gt;Activiti User Guide&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would need to call the following APIs&amp;nbsp;&lt;/P&gt;&lt;PRE class="" style="color: black; background: #eeeeee; border: 1px dashed #666666; padding: 1.25em 1.5625em 1.125em;"&gt;&lt;CODE data-lang="java" style="color: black;"&gt;ProcessInstance startProcessInstanceByMessage(String messageName); ProcessInstance startProcessInstanceByMessage(String messageName, Map&amp;lt;String, Object&amp;gt; processVariables); ProcessInstance startProcessInstanceByMessage(String messageName, String businessKey, Map&amp;lt;String, Object&amp;lt; processVariables);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The 'messageName' would be pre-defined in your process definition within 'messageRef' attribute of the 'messageEventDefinition'&lt;/P&gt;&lt;P&gt;However, looks like your scenario has multiple asynchronous events to determine when the process can be started&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;SPAN style="color: #727174; background-color: #ffffff;"&gt;My application expects a related group of events. I would like to construct a workflow that waits for all the events from the group to arrive (or times out), and then proceeds&lt;/SPAN&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So I think you would need to implement custom logic for this. You would need to create a set of asynchronous calls to these events and have the process triggered in the callback of the successful calls. Within the callback, you then call the startProcessInstanceByMessage API.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if this answers your questions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Thong Huynh&lt;/P&gt;&lt;P&gt;bp3‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2017 01:14:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2732#M710</guid>
      <dc:creator>thuynh</dc:creator>
      <dc:date>2017-01-11T01:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: Start a workflow if it has not been started?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2733#M711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An interesting problem and actually one that matches a project we completed recently for one of our clients.&lt;BR /&gt;Ignoring the message receiver classes for which I imagine you will create a message driven bean, rest endpoint or other custom handler to call into the workflow engine.&lt;BR /&gt;Your description indicates that it is possible for other messages to arrive while the process is being started or while a given event is processed and it is therefore possible to lose these messages.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;As such, you need to use a publish and subscribe pattern rather to simply throwing the events at the process engine and hoping they get caught.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the first message for a given groupID start the process AND put the message into a list (you can use an in memory store or DB table, really depends on the scenario).&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, when the process starts have it go out and look for messages (obviously there will be at least one) and retrieve them, basically a polling pattern, when all types are received, clear the group from the list and move on with the process.&lt;/P&gt;&lt;P&gt;This way we process as many messages as are available at any given moment and can't miss any since we are decoupled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this makes sense,&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;P&gt;&lt;A href="https://migration33.stage.lithium.com/t5/tag/bp3/tg-p"&gt;&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2017 19:52:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2733#M711</guid>
      <dc:creator>gdharley</dc:creator>
      <dc:date>2017-01-11T19:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Start a workflow if it has not been started?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2734#M712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Yes, that's it exactly. &amp;nbsp;There may be two or more "messages" concurrently trying to start a workflow. &amp;nbsp;I wanted to avoid race conditions, but like the idea of a workflow waiting for Activity messages to arrive, behind a gateway. &amp;nbsp;Very clean compared to polling. &amp;nbsp;Not afraid to poll, but would would have liked to avoid it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help,&lt;/P&gt;&lt;P&gt;-dan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2017 20:01:18 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2734#M712</guid>
      <dc:creator>blezek</dc:creator>
      <dc:date>2017-01-11T20:01:18Z</dc:date>
    </item>
    <item>
      <title>Re: Start a workflow if it has not been started?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2735#M713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah, it's a tough problem.&lt;/P&gt;&lt;P&gt;Honestly, other workflow engines (commercial) have an answer to this with what they call "durable messages", meaning you don't have to be listening for the message to act on it, if the process gets to it afterward, it is ok. I have been meaning to write something like this for Activiti, just haven't got to it yet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers mate and let us know if we can be of any help&lt;/P&gt;&lt;P&gt;Greg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2017 20:12:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/start-a-workflow-if-it-has-not-been-started/m-p/2735#M713</guid>
      <dc:creator>gdharley</dc:creator>
      <dc:date>2017-01-11T20:12:55Z</dc:date>
    </item>
  </channel>
</rss>

