Expand my Community achievements bar.

Custom Replication Event handler works Inconsistently

Avatar

Level 4

AEM version: 6.5.14 with Java 11

 

Following is my custom replication event handler class

 

(service = EventHandler.class, configurationPolicy = ConfigurationPolicy.REQUIRE,
        immediate = true, property = {
        Constants.SERVICE_DESCRIPTION + "=replication description",
        EventConstants.EVENT_TOPIC + "=" + ReplicationAction.EVENT_TOPIC})
public class ReplicationHandler implements EventHandler {

    some logs...
    
    extract ReplicationAction object from event.
    adding the action as a job to a particular Topic using JobManager.

}

 

When replication events triggers, some logs are printed and some code is executed. The problem that I'm facing is that this works inconsistently.
Sometimes the code doesn't execute and the logs are also not printed. 

The resources are replicated with no errors.
Has anyone faced this kind of issue before?

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

6 Replies

Avatar

Employee Advisor

@Vinit_Pillai 

Possibility is, the event handler is taking too much time to execute. If this time goes beyond 5 secs which is default TimeOut value, then the handler would be blacklisted and would never execute.

 

Hence, please consider using Sling Jobs or Job Consumer which will guarantee execution and does not follow 5 sec Timeout rule

Please look into below link for more info:https://felix.apache.org/documentation/subprojects/apache-felix-event-admin.html

 

Avatar

Level 4

@krati_garg Thanks a lot for quick and a good resolution.

I have updated the code in question to give more information regarding my situation.
Inside the handler we are doing only two things

  1. Extract ReplicationAction object from event.
  2. Add the action as a job to a particular Topic using JobManager.

This hardly takes us 5 lines of code

Avatar

Employee Advisor

You mentioned that replication is successful, so it cannot be an issue of blocked Replication Queues.

 

Also, as per above Code Snippet, you must be using Job Consumer. 

Can you refer below Code Snippet, and see if you haven't missed anything. Also, please put loggers inside Job consumer, logging status of execution. This would help us troubleshooting.

 

https://www.linkedin.com/pulse/aem-how-write-sling-jobs-aem-veena-vikraman/

 

@Vinit_Pillai 

 

Avatar

Level 4

@krati_garg 

We are logging in the consumers as well which are again not printed since replication handler is not handing over jobs to them.

and as per your link I have checked our consumers they are written correctly.

The first line in the event handler as well as the consumer is us logging.

whenever the issue occurs no logs from event handler as well as consumer is found in the log file.

Avatar

Level 5

This may be due to the parallel jobs running and not completed, can you change/increase the configuration for parallel jobs, this may give more time for job to complete.

VeenaK_0-1668728970727.png

Above image show the config details for the same.

Hope this helps!!!

Avatar

Level 4

@VeenaK  I don't think this is the issue since we have a total 5 custom consumers in our project.