<?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: Implementing Event Listeners in Activiti 7 in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/implementing-event-listeners-in-activiti-7/m-p/34645#M14629</link>
    <description>&lt;P&gt;Just wanted to comeback and update my post now that I found a solution to my problem in case anyone had a similar issue. For some reason the listeners will not fire after startup if I implement the interface without typing it to a certain event as shown both in the original post, and in the&amp;nbsp;&lt;A href="https://hub.alfresco.com/t5/alfresco-process-services/activiti-7-deep-dive-series-using-the-core-libraries/ba-p/288484#toc-hId--451664031" target="_self" rel="nofollow noopener noreferrer"&gt;acitiviti 7 deep dive series&lt;/A&gt;. i.e.&lt;/P&gt;&lt;PRE&gt;@Service
public class ProcessEventListener implements ProcessRuntimeEventListener {&lt;BR /&gt;    &lt;BR /&gt;    @Override public void onEvent(RuntimeEvent runtimeEvent){ &lt;BR /&gt;       ... &lt;BR /&gt;    } &lt;BR /&gt;} &amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;However, when I implement the event listener and type it to a specific event i.e.&lt;/P&gt;&lt;PRE&gt;@Service
public class ProcessEventListener implements TaskRuntimeEventListener&amp;lt;TaskCreatedEvent&amp;gt; {

    @Override
    public void onEvent(TaskCreatedEvent event){
         ...
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This will actually trigger whenever that event occurs within the runtime bundle services&lt;/P&gt;</description>
    <pubDate>Fri, 13 Mar 2020 17:21:31 GMT</pubDate>
    <dc:creator>hbobertz</dc:creator>
    <dc:date>2020-03-13T17:21:31Z</dc:date>
    <item>
      <title>Implementing Event Listeners in Activiti 7</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/implementing-event-listeners-in-activiti-7/m-p/34644#M14628</link>
      <description>&lt;P&gt;I am currently running the&amp;nbsp;&lt;A title="Aciviti Cloud Example" href="https://github.com/Activiti/activiti-cloud-examples" target="_blank" rel="noopener nofollow noreferrer"&gt;Activiti Cloud Example&lt;/A&gt;&amp;nbsp;version 7.10.m6, but I am having trouble implementing task and process listeners as outlined in&amp;nbsp;&lt;A title="the Deep Dive Series" href="https://hub.alfresco.com/t5/alfresco-process-services/activiti-7-deep-dive-series-using-the-core-libraries/ba-p/288484#toc-hId--451664031" target="_blank" rel="noopener nofollow noreferrer"&gt;the Deep Dive Series&lt;/A&gt; . Here are my implementaitons of the listeners as described by the deep dive series.&lt;/P&gt;&lt;PRE&gt;@Service
public class ProcessEventListener implements ProcessRuntimeEventListener {
    private Logger logger = LoggerFactory.getLogger(ProcessEventListener.class);

    @Override
    public void onEvent(RuntimeEvent runtimeEvent){

        System.out.println("\n\n------------------An Event Happened--------------------\n");
        if (runtimeEvent instanceof ProcessStartedEvent)
            logger.info("\n\n\nDo something, process is started: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof ProcessCompletedEvent)
            logger.info("\n\n\nDo something, process is completed: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof ProcessCancelledEvent)
            logger.info("\n\n\nDo something, process is cancelled: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof ProcessSuspendedEvent)
            logger.info("\n\n\nDo something, process is suspended: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof ProcessResumedEvent)
            logger.info("\n\n\nDo something, process is resumed: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof ProcessCreatedEvent)
            logger.info("\n\n\nDo something, process is created: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof SequenceFlowEvent)
            logger.info("\n\n\nDo something, sequence flow is taken: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof VariableCreatedEvent)
            logger.info("\n\n\nDo something, variable was created: " + runtimeEvent.toString());
        else
            logger.info("Unknown event: " + runtimeEvent.toString());

    }
}&lt;/PRE&gt;&lt;PRE&gt;@Service
public class TaskEventListener implements TaskEventListener {
    private Logger logger = LoggerFactory.getLogger(DerfTaskEventListener.class);

    @Override
    public void onEvent(RuntimeEvent runtimeEvent) {

        System.out.println("\n\n------------------An Event Happened--------------------\n");
        if (runtimeEvent instanceof TaskActivatedEvent)
            logger.info("Do something, task is activated: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof TaskAssignedEvent) {
            TaskAssignedEvent taskEvent = (TaskAssignedEvent)runtimeEvent;
            Task task = taskEvent.getEntity();
            logger.info("Do something, task is assigned: " + task.toString());
        } else if (runtimeEvent instanceof TaskCancelledEvent)
            logger.info("Do something, task is cancelled: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof TaskCompletedEvent)
            logger.info("Do something, task is completed: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof TaskCreatedEvent)
            logger.info("Do something, task is created: " + runtimeEvent.toString());
        else if (runtimeEvent instanceof TaskSuspendedEvent)
            logger.info("Do something, task is suspended: " + runtimeEvent.toString());
        else
            logger.info("Unknown event: " + runtimeEvent.toString());

    }
}&lt;/PRE&gt;&lt;P&gt;When I make the dockers, I get some logging on startup that indicates my listener class is being called as I get several logs similar to this:&lt;/P&gt;&lt;PRE&gt;example-runtime-bundle                  |
example-runtime-bundle                  | ------------------An Event Happened--------------------
example-runtime-bundle                  |
example-runtime-bundle                  | 2020-02-27 18:32:41.956  INFO [,,,] 1 --- [           main] o.a.c.runtime.DerfProcessEventListener   : Unknown event: RuntimeEventImpl [id=635d6bab-3230-4790-a964-cf0d266b3159, timestamp=1582828361955, &lt;BR /&gt;processInstanceId=null, processDefinitionId=SubprocessParent:1:838b625e-597f-11ea-b270-0242ac15000c, processDefinitionKey=SubprocessParent, processDefinitionVersion=null, businessKey=null, parentProcessInstanceId=null, &lt;BR /&gt;entity=ProcessDefinition{id='SubprocessParent:1:838b625e-597f-11ea-b270-0242ac15000c', name='Subprocess Parent', key='SubprocessParent', description='null', formKey='null', version=1}]&lt;/PRE&gt;&lt;P&gt;However, after the containers are finished initializing and are all running. Using the default postman collection to start processes or claim/complete tasks doesn't seem to give me any logging from my listeners. I just recieve some general logging from nginx and notifications such as:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;activiti-cloud-notifications-graphql    | 2020-02-27 19:09:15.337  INFO [,d5415bee8feab613,a7e2bdbe6a2824ab,false] 1 --- [9iP_nWL6Vke1w-2] g.e.c.EngineEventsConsumerMessageHandler : Recieved source message with routingKey: engineEvents.rb.default-app
nginx                                   | 172.24.0.1 - - [27/Feb/2020:19:09:15 +0000] "POST /rb/v1/tasks/a0390c00-598f-11ea-920a-0242ac18000a/complete HTTP/1.1" 200 1164 "-" "PostmanRuntime/7.22.0"&lt;/PRE&gt;&lt;P&gt;Is there a different way to create event listeners? Or is there something I'm missing in my implementation of the eventListeners?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 19:13:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/implementing-event-listeners-in-activiti-7/m-p/34644#M14628</guid>
      <dc:creator>hbobertz</dc:creator>
      <dc:date>2020-02-27T19:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Implementing Event Listeners in Activiti 7</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/implementing-event-listeners-in-activiti-7/m-p/34645#M14629</link>
      <description>&lt;P&gt;Just wanted to comeback and update my post now that I found a solution to my problem in case anyone had a similar issue. For some reason the listeners will not fire after startup if I implement the interface without typing it to a certain event as shown both in the original post, and in the&amp;nbsp;&lt;A href="https://hub.alfresco.com/t5/alfresco-process-services/activiti-7-deep-dive-series-using-the-core-libraries/ba-p/288484#toc-hId--451664031" target="_self" rel="nofollow noopener noreferrer"&gt;acitiviti 7 deep dive series&lt;/A&gt;. i.e.&lt;/P&gt;&lt;PRE&gt;@Service
public class ProcessEventListener implements ProcessRuntimeEventListener {&lt;BR /&gt;    &lt;BR /&gt;    @Override public void onEvent(RuntimeEvent runtimeEvent){ &lt;BR /&gt;       ... &lt;BR /&gt;    } &lt;BR /&gt;} &amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;However, when I implement the event listener and type it to a specific event i.e.&lt;/P&gt;&lt;PRE&gt;@Service
public class ProcessEventListener implements TaskRuntimeEventListener&amp;lt;TaskCreatedEvent&amp;gt; {

    @Override
    public void onEvent(TaskCreatedEvent event){
         ...
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;This will actually trigger whenever that event occurs within the runtime bundle services&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 17:21:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/implementing-event-listeners-in-activiti-7/m-p/34645#M14629</guid>
      <dc:creator>hbobertz</dc:creator>
      <dc:date>2020-03-13T17:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Implementing Event Listeners in Activiti 7</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/implementing-event-listeners-in-activiti-7/m-p/34646#M14630</link>
      <description>&lt;P&gt;Thanks for providing your solution. I have the same issue.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 05:26:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/implementing-event-listeners-in-activiti-7/m-p/34646#M14630</guid>
      <dc:creator>samwang</dc:creator>
      <dc:date>2020-04-06T05:26:14Z</dc:date>
    </item>
  </channel>
</rss>

