EventHandler vs Preprocessor | Community
Skip to main content
Level 3
October 16, 2024
Solved

EventHandler vs Preprocessor

  • October 16, 2024
  • 1 reply
  • 476 views

Would like to ask what the difference between EventHandler vs Preprocessor?
We have a use case that certain property would be added in case there would be a publish action. Currently, it is applied to an event handler, and it seems that this properties were intermittently applied, whereas there is another property we added on preprocessor, and seems to be working fine.

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

Hi @lyonmartin ,

EventHandler are fired asynchronously and hence orders are not maintained.

Also it doesn't notify if the event action completed successfully, as well as it doesn't guarantee completion.

 

Pre-processor have following advatages-

  • this is part of AEM replication api, and has dedicated entry point which run just before replication is triggered always
  • do not need to create any additional replication agents or configurations
  • as this is part of replication flow, it is guarantee it will be run, unlike event listener you do not have to worry if you have picked up appropriate event topic, or if the event will be blacklisted etc
  • it gives you information about replication action type (e.g. Activation, Deactivation etc), path and others
  • finally it allows you to stop replication process

https://dileepakv.blogspot.com/2018/01/aem-replication-preprocessor.html

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/replication/Preprocessor.html#:~:text=The%20Preprocessor%20is%20a%20service,already%20performed%20at%20this%20state.

https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/core/src/main/java/com/adobe/acs/samples/replication/impl/SampleReplicationPreprocessor.java

Thanks

 

1 reply

MukeshYadav_
Community Advisor
MukeshYadav_Community AdvisorAccepted solution
Community Advisor
October 16, 2024

Hi @lyonmartin ,

EventHandler are fired asynchronously and hence orders are not maintained.

Also it doesn't notify if the event action completed successfully, as well as it doesn't guarantee completion.

 

Pre-processor have following advatages-

  • this is part of AEM replication api, and has dedicated entry point which run just before replication is triggered always
  • do not need to create any additional replication agents or configurations
  • as this is part of replication flow, it is guarantee it will be run, unlike event listener you do not have to worry if you have picked up appropriate event topic, or if the event will be blacklisted etc
  • it gives you information about replication action type (e.g. Activation, Deactivation etc), path and others
  • finally it allows you to stop replication process

https://dileepakv.blogspot.com/2018/01/aem-replication-preprocessor.html

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/replication/Preprocessor.html#:~:text=The%20Preprocessor%20is%20a%20service,already%20performed%20at%20this%20state.

https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/core/src/main/java/com/adobe/acs/samples/replication/impl/SampleReplicationPreprocessor.java

Thanks