Custom Replication Event handler works Inconsistently | Community
Skip to main content
Level 3
November 17, 2022

Custom Replication Event handler works Inconsistently

  • November 17, 2022
  • 2 replies
  • 2390 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

krati_garg
Adobe Employee
Adobe Employee
November 17, 2022

@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

 

Level 3
November 17, 2022

@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

Level 3
November 18, 2022

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 

 


@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.

Level 4
November 17, 2022

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.

Above image show the config details for the same.

Hope this helps!!!

Level 3
November 18, 2022

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