Hi All,
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?
Solved! Go to Solution.
Views
Replies
Total Likes
You should observe the replication status of the page:
(ReplicationStatus ("The Adobe AEM Quickstart and Web Application.") )
ReplicationStatus status = page.adaptTo(ReplicationStatus.class);
if (status.isActivated()) {
...
}
The "tricky" part is to determine the exact time when to perform this check.
Jörg
Views
Replies
Total Likes
You may use workflows or sling events
For workflow- step 1 would be to publish and step2 to send emails. Configure the workflow to trigger automatically/manually for any activation under the project structure.
Views
Replies
Total Likes
Your solution will not work for this scenario if cache validation failed for page due to web server not running.
Mail has to be sent once cache invalidation(not after the successful replication from author to publish) is done for scaffolding page.
Views
Replies
Total Likes
Sling event could work in this use case. Get hold of specific flush agents, listen to whenever they get triggered and check specific headers/path and wait for 200 response to trigger the email.
dispatcher handler-
/dispatcher/invalidate.cache
Views
Replies
Total Likes
Great response Gaurav Behl!
Views
Replies
Total Likes
You should observe the replication status of the page:
(ReplicationStatus ("The Adobe AEM Quickstart and Web Application.") )
ReplicationStatus status = page.adaptTo(ReplicationStatus.class);
if (status.isActivated()) {
...
}
The "tricky" part is to determine the exact time when to perform this check.
Jörg
Views
Replies
Total Likes
Gaurav,
Thanks for your response.
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);
status.isPending/isDelivered
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.
Views
Replies
Total Likes
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 -
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.
Adobe CQ Help | Creating Replication Event Handlers for Adobe Experience Manager
Creating an Event Listener for Adobe Experience Manager 6.4
Adobe Experience Manager Help | Creating an Adobe Experience Manager Event Listener that tags pages
http://www.sotheanim.com/27-how-to-write-a-replication-event-listener
Views
Replies
Total Likes