We have to trigger mail at Publish instance for the below scenario.
Consider page(with scaffolding content) is replicated from author to publish. Scaffolding content is considered as page
When we publish the page from author to publish, two entity(page and scaffolding page) will be replicated to publish instance. Flush agent is configured at publish instance to invalidate both the page and scaffolding page.
Mail has to be sent once cache invalidation(not after the successful replication from author to publish) is done for scaffolding page.
How to identify the cache invalidation successful event for particular path at publish instance?
I'm not sure if the org/apache/sling/event/notification/job/FINISHED is the correct topic to listen.
Try these - ReplicationAction.EVENT_TOPIC or ReplicationActionType.Activate or Delete whatever is configured in your flush agents
In my mind, there couple of ways to tackle this. See what works best -
implement EventHandler, listen to flush event, get the ReplicationAction from event and then get ReplicationStatus from it
listen to content page changes/creation, trigger the replication agents and flush agents programmatically using ReplicationOptions (use filter to get specific agents) so that you can control the agents/data and perform the entire activity in same session. Get replication status from this object
JCR event (use it only if it justifies the need as they operate at low level)
implement EventListener, register to a particular event, use observationmanager to get either nodes or current session form event and then get replicationaction/status from it
make sure to unregister the listener/close session on deactivate otherwise you may run into other issues
path is available in both event & replicationaction if you listen to replicationaction otherwise if you listen to content page then also you would have the path to proceed further.
header is same as path for flush agents, however replicationaction/replicationoptions would give you other headers as required.
I listened on event for flush job completion(org/apache/sling/event/notification/job/FINISHED) for scaffolding page.
On handle event method, I tried to check the below status using replication status API whether it is delivered(cache invalidation done) or not. It is returning false and making the thread to sleep for few more seconds. But still it is returning value as false for the below code after pausing the thread.
ReplicationStatus status = page.adaptTo(ReplicationStatus.class);
Can u explain me how to do below things in event handler based on event path ?
check specific headers/path and wait for 200 response to trigger the email.