Expand my Community achievements bar.

Trigger custom workflow on page publish

Avatar

Level 3

Hi,

 

I have a requirement where I need to call and API to trigger crawler when a page is published. Purpose is to trigger crawler as soon as page is published so the content changes can be crawled.

 

I can do a custom workflow to trigger crawler but not sure how to trigger that custom workflow when editor hits publish.

 

I read two ways of doing it but not clear which option is better than the other.

 

First is to write custom event handler which will be triggered at page activation and executes custom workflow.

 

Second is to create a model and set the custom workflow and then trigger that by adding launcher with condition "jcr:content/cq:lastReplicationAction == Activate" on modified.

 

I am not sure if both are doable and which is the right way of doing to yield desired results without affecting performance. 

 

Any help on this would be greatly appreciated.

 

Thanks in advance!

 

1 Reply

Avatar

Community Advisor

Hi @hptarora ,
Both of the options you mentioned are viable, but there are key differences in terms of flexibility, complexity, and performance.
For most use cases, Option 2 (Workflow Launcher) is the preferred option because it leverages AEM's optimized workflow engine for asynchronous processing, which is better suited for handling triggers like page activation with minimal performance impact.
Option 1 (Custom Event Handler) can be used when you need more control over the event trigger, but it may require more careful performance management, especially with high traffic or frequent page activations.

Thanks,
Madhur