Implementing the Event Listener

To implement the event listener:

Procedure

  1. Employ the Traffic Event Listener interface (introduced in Event Listener API) as shown in the following example:
    package com.company.extension;
    public class CustomProcessor implements TrafficEventListener{
         public void handleEvent(TrafficEvent event){
            //write your custom code here
          }
    }
  2. Annotate your code to ensure that the processor is identified correctly for callbacks on events related to the specific endpoints it is written to handle:
    @ProcessorBean(enabled=true, name=”com.company.extension.CustomProcessor”, immediate=true)
    public class CustomProcessor implements TrafficEventListener{
         public void handleEvent(TrafficEvent event){
            //write your custom code here
        }
    }
    The annotation identifies the following properties:
    • enabled: Identifies if the processor is to be enabled.
    • name: Identifies the unique name of the processor as configured in API Settings (see marked area in ‘red’ in the following screenshot).
    • immediate: Identifies if the processor is enabled immediately.
    Note: The name used in the annotation for the Processor MUST be the same as configured on the portal for the Endpoint>Pre/Post Processing, as shown in the following screenshot: