event listeners

Hi community.

I am trying to create an event listener, so far, I just want to log a message when my listener is called. See my class below:

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuxeo.ecm.core.event.EventBundle;
import org.nuxeo.ecm.core.event.PostCommitEventListener;

public class EventForwarder implements PostCommitEventListener{

    private static final Log log = LogFactory.getLog(EventForwarder.class);

    public void handleEvent(EventBundle arg0) {
        log.warn("===========New Event=========");
    }
}

I added listener-contrib.xml file(see below) in NUXEO_HOME/nxserver/config

<?xml version="1.0"?>
<component name="event-forwarder" version="1.0">
  <extension target="org.nuxeo.ecm.core.event.EventServiceComponent"
             point="listener">
    <listener name="rabbitMQ" async="true" priority="666" postCommit="true"
              class="{my-package}.EventForwarder">
      <event>documentCreated</event>
    </listener>
  </extension>
</component>

I also added the jar containing my class in NUXEO_HOME/nxserver/bundles directory. After restarting nuxeo and creating a couple of documents from the UI, I do not see the line I am writing in the logs. Is there anything I am missing to register the listener?

Thank you in advance.

0 votes

0 answers

1987 views

ANSWER

First uncomment this part in lib/log4j.xml and find out if your component is really seen and loaded:

&lt;!-- Uncomment for components registration info --&gt;
&lt;!--
&lt;category name=&quot;org.nuxeo.runtime.model.impl&quot;&gt;
  &lt;priority value=&quot;INFO&quot; /&gt;
&lt;/category&gt;
--&gt;
04/07/2017