Using An Event Listener
For detailed information about configuration files, configuration layers and an explanation of the configuration-root placeholder used in the file paths in this section, see the Escenic Content Engine Server Administration Guide.
The event listeners executed by the
Content Engine
are defined in a configuration file called
configuration-root/Initial.properties
.
To enable the NewArticleNotifier
listener, therefore,
you must add a declaration to Initial.properties
in
one or more of your configuration layers. For example:
service.60-articlenotifier=/com/mycompany/NewArticleNotifier
You must also create a properties file for the listener called
NewArticleNotifier.properties
, and save it in the
location you have specified in the same configuration layer(s) -
configuration-root/com/mycompany/NewArticleNotifier.properties
in this case. The file must at least contain $class
and eventManager
entries. In the particular case of
the NewArticleNotifier
example you will also need to
set the email
and emailSender
properties. For example:
$class=com.mycompany.events.NewArticleNotifier eventManager=/io/api/EventManager email=sample@mycompany.com emailSender=/neo/io/services/MailSender
Finally, you must make sure that the email sender declared in
configuration-root/com/mycompany/NewArticleNotifier.properties
.
is correctly configured. Create a configuration file called
configuration-root/neo/io/services/MailSender.properties
and configure it with appropriate settings. For example:
enabled=true mailHost=smtp.mycompany.com defaultSender=noreply@mycompany.com
If you have trouble running your event listener, try checking the
View Services page of the
escenic-admin
web application or the
Content Engine's
log files.
Performance monitoring
If you want to use the Content Engine's HitCollector
component to gather statistics about the performance of an event
listener, then you can do so by adding one more line to its properties
(i.e.,
configuration-root/com/mycompany/NewArticleNotifier.properties
in the case of this example):
collector=./NewArticleNotiferCollector
You will then also need to create a configuration file for the collector
you have declared
(configuration-root/com/mycompany/NewArticleNotifierCollector.properties
in this case):
$class=neo.util.stats.HitCollector denominator=events handled description=Events handled by 'com.mycompany.events.NewArticleNotifier' failureDescription=failed events
The information gathered by the hit collector can be viewed on the
escenic-admin
web application's Performance
Summary page. See
here
for information about escenic-admin
.